In my application when I open page X I expect to see either element A or element B. They are placed in different locations in DOM and can be found using their ids, for example driver.findElement(By.id("idA"))
How can I ask webdriver to find either A or B?
There is method driver.findElements(By) which will stop waiting when at least one element is found, but this method forces me to use the same locator for A and B.
What is the proper way to reliably find either A or B, so that I don’t have to wait implicit timeout?
Element with id I1 or element with id I2
xpath:
//E1[@id=I1] | //E2[@id=I2]css:
css=E1#I1,E2#I2don’t forget about fluentWait mechanism:
you can get more info about fluentWait here
IMHO solution to your issue be like:
FYI: here is nice xpath,cssSelector manual
hope this helps you.