Reputation: 7493
I have a Windows Modal Dialog that appears at times for some tests and then other times it does not appear.
I know when it will possibly show up. I want to be able to grab the window handle of the modal dialog and send the enter key to dismiss it.
Is it possible to detect if a modal dialog is present using the Selenium web driver?
Upvotes: 0
Views: 2187
Reputation: 1956
After we perform the action which opens Modal Dialog box, Try Using Robot class, Used Manual wait of 7 sec though its not good practice, you can change it as per your requirement. See if that works.
Robot robot = new Robot();
Thread.sleep(7000);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
Upvotes: 0
Reputation: 815
If this is a javascripty alert box then
IAlert alert = driver.SwitchTo().Alert();
alert.Accept();
Should be sufficient to acknowledge.
Upvotes: 1