Edge WebDriver can't handle Modal Windows

Issue #17848293 • Assigned to Steven K.

Details

Author
Louis Q.
Created
Jun 11, 2018
Privacy
This issue is public.
Found in
  • Microsoft Edge
Reports
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
    continue.

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

webDriver.findElement(By.name("firstReport")).click();
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

Attachments

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.

    Thanks,

    Steve

  • 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~~~~0.0.1.0

    • unzip public-repro.zip
    • Run Express server

    open gitbash to serverA folder

    .\public-repro\repro\serverA

    npm update

    node index.js

    optional: verify webserver by opening URL:http://127.0.0.1:3000/edgetest.html

    • run webDriver from command line

    open gitbash to webdriverjavaextensionapp folder containing the pom.xml file

    BUILD

    mvn clean compile package

    run

    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.

    Thanks,
    Louis

  • 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.

    Steve

  • 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 http://127.0.0.1:3000/edgetest.html , 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,
    Louis

  • 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.

    https://stackoverflow.com/questions/45476200/in-selenium-how-to-handle-a-new-window

    http://toolsqa.com/selenium-webdriver/switch-commands/

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

    Steve

  • 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.

    Louis

  • 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:

    waitSeconds(5);
    webDriver.findElement(By.name("firstReport")).click();

    Louis

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

Sign in