Selenium Wait for any of the Element to become visible.

When I click on a specific button, my test site will open a modal window.

But the open modal window is different, or it opens with modal window 1 or modal window 2

Both have different names, different options, and different locators. Now I have to wait until modal window open Either 1 or 2.

Can I wait until one modal window (WebElement) appears?

I searched in WebDriverWait methods, but all methods wait until a certain WebElement becomes visible or clickable.

I cannot find a better way to wait until one is visible.

Could you suggest any one method to solve this problem?

+4
source share
1

or

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
    ExpectedConditions.visibilityOfElementLocated(By.id("id1")),
    ExpectedConditions.visibilityOfElementLocated(By.id("id2"))
));

cssSelector ,

wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#id1, #id2"));
+7

Source: https://habr.com/ru/post/1672889/


All Articles