Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

java - Selenium Wait for anyone of Element to visible

While Clicking a particular button - my test site will open modal window.

But the modal window opens are differ, either it opened with modal window 1 or modal window 2

Both are having different title, different options and different locators. Now I should have to wait until the modal window open Either 1 or 2.

Is it possible to wait until either one modal window (WebElement) is visible?

I have searched in WebDriverWait methods, but all methods are to wait until a particular WebElement to visible or clickable.

I can't find a better method to wait until either one is visible.

Could you suggests any one method to solve this situation?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use or expected conditions for that

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

Or use cssSelector or ,

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...