rsaha77 rsaha77 - 1 month ago 9x
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.


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.