Commit fb7b136c authored by Arsam Ali's avatar Arsam Ali

added new feature file , stp and page file for burjul arab web

parent c80906c2
Feature: Search and reserve at Burj Al Arab
Scenario: Search for Burj Al Arab and click on reserve
Given I am on the Google homepage For Burjul Arab Web
When I search for "Dubai Burjul Arab"
And I click on the link for Burj Al Arab
And I click on the reserve button
Then I wait for 3 seconds on the page
package org.example.BurjulArabPage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.example.NisumSearchPage.NisumPage;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
public class BurjulArabPage {
WebDriver driver;
private static final Logger log = LogManager.getLogger(NisumPage.class);
By searchBox = By.name("q");
By burjAlArabLink = By.xpath("//a[@href='https://www.jumeirah.com/en/stay/dubai/burj-al-arab-jumeirah']//h3[@class='LC20lb MBeuO DKV0Md']");
By reserveButton = By.xpath("//button[normalize-space()='RESERVE']");
public BurjulArabPage(WebDriver driver) {
this.driver = driver;
}
public void searchForText(String text) {
WebElement searchField = driver.findElement(searchBox);
searchField.sendKeys(text);
searchField.submit();
}
public void clickBurjAlArabLink() {
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
log.info("Burjul arab Page link");
WebElement link = wait.until(ExpectedConditions.elementToBeClickable(burjAlArabLink));
link.click();
}
public void clickReserveButton() {
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement reserveBtn = wait.until(ExpectedConditions.elementToBeClickable(reserveButton));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", reserveBtn);
}
public void waitForSeconds(int seconds) throws InterruptedException {
Thread.sleep(seconds * 1000);
}
}
package org.example.BurjulArabSteps;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.example.BurjulArabPage.BurjulArabPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class BurjulArabSteps {
WebDriver driver;
BurjulArabPage burjulArabPage;
@Given("I am on the Google homepage For Burjul Arab Web")
public void iAmOnTheGoogleHomePage() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.com/");
burjulArabPage = new BurjulArabPage(driver);
}
@When("I search for {string}")
public void iSearchFor(String searchText) {
burjulArabPage.searchForText(searchText);
}
@When("I click on the link for Burj Al Arab")
public void iClickOnTheLinkForBurjAlArab() {
burjulArabPage.clickBurjAlArabLink();
}
@When("I click on the reserve button")
public void iClickOnTheReserveButton() {
burjulArabPage.clickReserveButton();
}
@Then("I wait for {int} seconds on the page")
public void iWaitForSecondsOnThePage(int seconds) throws InterruptedException {
burjulArabPage.waitForSeconds(seconds);
driver.quit();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment