Edge WebDriver can't handle Modal Windows

Issue #17848293 • Assigned to Steven K.


Louis Q.
Jun 11, 2018
This issue is public.
Found in
  • Microsoft Edge
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

I am writing tests and there are some places that when I click on a button, a new browser (as in New modal window) will be opened. I have already handled them by using webDriver.switchTo().window(windowHandle), and it works fine on 3 browsers Chrome, Firefox and Internet Explorer 11.

Now I am trying to run these tests on Microsoft Edge. It works as expected, except when it comes to modal windows:

  1. When I let the tests run to the point I click on the button, I saw
    that the Modal Window was opened and disappeard in a blink, it was
    not in the background as well.

  2. When I debug the tests to the click() action, then the Modal window
    was opened and stayed there after the click(), and the tests could

I thought it was fast, so I added a wait after click() like this:

Thread.sleep(5000); // wait 5 seconds

but the Modal window always disappeared right after the click() action. I also tried with:

js.executeScript("arguments[0].click();", webDriver.findElement(By.name("firstReport")));

But the same result. The Modal Window only stays when I choose Debug instead of Run.

My enviroment: IntelliJ with Selenium v.3.12, MicrosoftWebDriver.exe Version: 5.16299 for Win10 OS Build Release 16299 (from Microsoft WebDriver)

EXPECTED RESULT: Modal Window will be opened and stayed

ACTUAL RESULT: Modal Window was opened and disappeared/closed immediately


Comments and activity

  • This is HTML of the button:

          Submit report 
  • Microsoft Edge Team

    Changed Assigned To to “Steven K.”

  • Hi Louis,

    Will you provide a repro for this?

    I am wondering how you are displaying the modal.  Does your call to sendReportAction() modify the display property?  A simplified repro would really help.



  • I am attaching my modal testing.  Below are the step to execute my no repro.

    Repro Steps

    // assumes maven installed and in path: choco install maven -y
    // assumes nodejs installed and in path: choco install nodejs.install -y
    // assumes java 1.8.x installed and in path: choco install jdk8 -y
    // assumes gitbash installed: choco install git -y

    • install the Microsoft webdriver.exe and make sure it is in your path

    // For insider releases - use this command in an Administrator PowerShell

    DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~

    • unzip public-repro.zip
    • Run Express server

    open gitbash to serverA folder


    npm update

    node index.js

    optional: verify webserver by opening URL:

    • run webDriver from command line

    open gitbash to webdriverjavaextensionapp folder containing the pom.xml file


    mvn clean compile package


    java -jar target/AppFatJar-1.0-SNAPSHOT-spring-boot.jar

  • Hi Steven,

    Thank you for looking into the issue. About your question if action sendReportAction() modifies the display property, I am attaching the JS of this action.

    About the repro, I also provide the test code, becasue it is the start point of the test, so just create EdgeDriver and click on this button. I hope it could help, and sorry if I can’t provide more information.


  • Hi Louis,

    Were you able to run the repro I provided?

    I am not certain there is enough code provided to run your repro.  I.e. the parameters for the button action are not set and it appears the javascript requires Struts?

    If you provide a complete repro, I can test it.  However, my repro is showing that modals are handled properly for the case I created.


  • Hi Steven,

    sorry for a late reply. Unfortunately, I was not able to run your repro. My env is Linux, so I use RemoteWebDriver to a Selenium Node which I don’t have access to.

    But I was able to run the Express Server and have a look at , I see that your Modal is still attached to browser. In my case, when I click on that button, it opens a new browser/window, that’s where I guess windleHandle is lost ?!

    I was asking my dev team to pack a reasonable repro which introduces this modal window thingy, but no result. Sorry for that.

    Thanks and regards,

  • Hi Louis,

    I understand the issue now.  You will have to use the driver.SwitchTo().window() method to first get access to the new window.  Here are some examples of how to do that.



    Let me know if using the switchTo().window(handle) does not solve the issue.


  • Hi Steve,

    Yes, I have used the method driver.SwitchTo().window() already, and it works really well with IE11, Chrome and FF in this regard.

    But the issue with Edge is that, when I let the tests run, this new window/browser is opened and closed immediately, it is completely gone after action click(). That’s why when it reaches to driver.SwitchTo().window(), there is no window to switch!

    When I run the tests with Debug mode, steps by steps, this new window/browser is opened and displayed, therefore I can switchTo(), and the tests carry on.

    However, I just had a workaround for this. Before action click() to open this new window, I put a Thread.sleep() 5 seconds and it somehow works! Maybe Edge can take it into account for an improvement.

    Thanks for your time looking into this issue.


  • I am attaching 2 files:

    • video file without_sleep_before_action_click.mp4: you can see in this video, the click() action was executed, and in a blink, the new window is gone.

    • image with_sleep_before_action_click.png: if I put a Thread.Sleep() 5 seconds before click(), then the new window is displayed, like this:



You need to sign in to your Microsoft account to add a comment.

Sign in