Issue
I got an issue with Selenium throwing timeout exception
because of a pop up window
unexpected alert open
not provide any stacktrace information)
Command duration or timeout: 5 milliseconds
The alert has OK
and CANCEL
buttons. I know two ways to handle this
The first way is reopen a new session
driver.quit();
driver = new ChromeDriver();
Second way is using Robot class
Robot r = new Robot();
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
However, this methods are not time efficient. Is there any better way?
Solution
This should do the trick:
driver.switchTo().alert().accept();
Answered By - Nathan Merrill
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.