rsaha77 rsaha77 - 1 year ago 139
Java Question

Program stuck after opening a pop up using selenium webdriver

The tool clicks a button and a modal window appears (where I need to fill in some information and later move to parent window). But as soon as the new modal window appears, my code stops. The code resumes once I manually close the new pop up window.

Since the code itself halts, I am not able to perform any actions in the new pop up window, nor in the parent window.

System.out.println ("Up");
WebElement addButton = driver.findElement("btnAdd")); ();
System.out.println ("Down");

In the above code, Up gets printed in the console while Down doesn't get printed until I manually close the pop up window.

Answer Source

Finally a solution after wasting a lot of days.

The only way is to not use showModalDialog. This can be done by adding the folowing before the .click() :

((JavascriptExecutor) driver).executeScript("window.showModalDialog =;");

which will call instead of window.showModalDialog.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download