Untitled

 avatar
unknown
plain_text
24 days ago
1.1 kB
14
Indexable
public static class HotelSearchPage {
		WebDriver driver;
		WaitUtils wait;

		By destinationInput = By.xpath(
				"//input[contains(@placeholder,'Search') or contains(@placeholder,'City') or contains(@placeholder,'Destination')]");
		By searchButton = By.xpath("//button[@type='submit'] | //button[contains(text(),'Search')]");
		By hotelNames = By.xpath("//h4 | //h3 | //strong");
		By hotelPrices = By.xpath("//*[contains(text(),'USD') or contains(text(),'₹') or contains(text(),'$')]");

		public HotelSearchPage(WebDriver driver) {
			this.driver = driver;
			wait = new WaitUtils(driver);
		}

		public void searchHotel(String city) {
			try {
				WebElement destination = wait.waitForVisible(destinationInput);
				destination.clear();
				destination.sendKeys(city);
			} catch (Exception e) {
				System.out.println("Destination input not found.");
			}

			try {
				WebElement searchBtn = wait.waitForClickable(searchButton);
				wait.jsClick(searchBtn);
			} catch (Exception e) {
				System.out.println("Search button not available, continuing execution.");
			}
		}
}
Editor is loading...
Leave a Comment