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:-
- using Action --> moveToElement --> perform()
- using JS Execution --> scrollToView, scrollBy(0,100) for example to make the page scroll down
- 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.
- 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
- 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
CodePudding user response:
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.
CodePudding user response:
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.
