Answer the question
In order to leave comments, you need to log in
How to wait for an alert to appear on a page using selenium webdriver in javascript?
There is a page. When you switch to it, alert may appear, or it may not. I want to make an implementation so that when going to the page, the driver waits for 5 seconds for alert, and if it does not appear, then continue the test further. I found several implementations for various languages, but they did not work on js.
Answer the question
In order to leave comments, you need to log in
Try like this:
try {
Thread.sleep(5000);\\Ждём пять секунд
} catch (InterruptedException e) {
}
if (driver.switchTo().alert() != null) {
\\Если алерт есть, делаем то-то...
}
\\...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question