Bishoy Ezzat
Bishoy Ezzat

Reputation: 41

How to locate an element on this page?

I tried a lot to locate elements on this page with this link

ALL I want to do is to select "1 queen bed" or "1 double large bed" and then select amount from the drop down list then press, I'll reserve button.

But I totally failed trying all of these:-

  1. using Action --> moveToElement --> perform()
  2. using JS Execution --> scrollToView, scrollBy(0,100) for example to make the page scroll down
  3. using all types of locators (ID, xPaths, cssSelectors, names) but always an error message that Expected condition failed: waiting for visibility of element located by By.xpath- By.id .. etc.
  4. tried to search for an iFrame but I didn't find but I think there are some but not related to the locators I want
  5. Thread.sleep() to wait for a time if the element is not loaded on the web page.

I am using Selenium JAVA TestNG

so in the page I write this function:-

Page class I write this function :-

private By btnBed = By.xpath("(//i[@class='bicon bicon-double'])[1]");

     public void clickBed(){
//        JavascriptExecutor exe = (JavascriptExecutor)driver;
//        exe.executeScript("window.scrollBy(0,1000)");
    click(btnBed);
}

In my Test I write this:-

hotelPage.clickBed();

Error message:-

Expected condition failed: waiting for visibility of element located by By.xpath

Upvotes: 0

Views: 110

Answers (2)

Bishoy Ezzat
Bishoy Ezzat

Reputation: 41

The problem was that this page was opened in a new tab so the code can't locate any elements on the screen. So I just switch tabs, the code works fine.

Upvotes: 2

Rob
Rob

Reputation: 44

ALL I want to do is to select "1 queen bed" or "1 double large bed"

I inspecting the DOM on the link you provided, I see that it is radio button that you might want to select. Try locate the radio element button something like this

<input type="radio" value="1" name="bedPreference_78883120" data-bed-type="">

Locate by name

By.name("bedPreference_78883120")

then perform the click.

Upvotes: 0

Related Questions