Skip to content
Advertisement

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

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement