I have two elements I can wait for, I want to wait until either of them appears on the page.
I am trying to use xpath locator. But it is not working.
By.xpath("//*[(contains(@id,'idNumber1')) or (contains(@id,'idNumber2'))]"));
Is this achievable?
Please help me out.
It is possible to wait for one of two elements in the page using ExpectedConditions.or():
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
ExpectedConditions.elementToBeClickable(By.id("idNumber1")),
ExpectedConditions.elementToBeClickable(By.id("idNumber2"))
));
You can also do an OR with a CSS selector using a comma ,:
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#idNumber1, #idNumber2"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With