Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional window handle if alert is open #780

Closed
codingphil opened this issue Jun 9, 2017 · 6 comments
Closed

Additional window handle if alert is open #780

codingphil opened this issue Jun 9, 2017 · 6 comments
Assignees

Comments

@codingphil
Copy link

codingphil commented Jun 9, 2017

Platform and application details

  • Platform: Windows 10 Creators Update
  • Firefox: 53.0.3 (64bit)
  • Selenium: 3.4.0 (Java)

Steps to reproduce

Execute the following Java Selenium test:

  public void testWindowHandlesIfAlertIsOpen() {
    String geckoDriverPath = ""; // TODO: Add your geckodriver path here
    File firefoxExe = ""; // TODO: Add your firefox path here
    
    System.setProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY, geckoDriverPath);
    FirefoxOptions options = new FirefoxOptions()
        .setLogLevel(Level.ALL)
        .setBinary(new FirefoxBinary(firefoxExe))
        .setProfile(new FirefoxProfile()); // if you remove this line the test succeeds
    DesiredCapabilities caps = options.addTo(DesiredCapabilities.firefox());

    RemoteWebDriver driver = new FirefoxDriver(caps);
    try {
      driver.navigate().to("https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert");
      driver.switchTo().frame(driver.findElementById("iframeResult"));
      WebElement alertButton = driver.findElementByTagName("button");
      alertButton.click();
      Set<String> windowHandles = driver.getWindowHandles();
      assertEquals(1, windowHandles.size()); // FAILS!
    }
    finally {
      if (driver != null) {
        driver.quit();
      }
    }
  }

The test fails with java.lang.AssertionError: expected:<1> but was:<2>
I also tried this test with a simple page without iframes (same result) but I did't found a public available page with an alert.

It seems that adding the FirefoxProfile to the FirefoxOptions causes the issue.
If you remove the .setProfile(new FirefoxProfile()) from the test the test succeeds.

What I also noticed is that with the .setProfile(new FirefoxProfile()) the alert is displayed as a separate Win32 window. Without the setProfile the alert is displayed "inline". Not sure if this is relevant for the issue.

A trace level log:
geckodriver_trace.txt

@andreastt
Copy link
Contributor

Thanks for this bug report! This sounds like a bug in https://searchfox.org/mozilla-central/rev/a798ee4fc323f9387b7576dbed177859d29d09b7/testing/marionette/driver.js#170-194.

Out of curiosity, did you also test with Firefox Nightly?

@codingphil
Copy link
Author

The test fails too with the todays nightly build 55.0a1.
Log:
geckodriver_log_55.0a1.txt

@whimboo
Copy link
Collaborator

whimboo commented Jun 19, 2017

As it looks like a chrome window handle is getting squeezed into this list. My patch on https://bugzilla.mozilla.org/show_bug.cgi?id=1368965 got landed 5 days ago, which should fix that.

@codingphil, can you please re-test with the latest nightly? If it's not fixed I would have to take another look at your example.

@codingphil
Copy link
Author

codingphil commented Jun 20, 2017

I can confirm that the bug is fixed in the nightly build 56.0a1 (2017-06-19) (64-bit).
Thanks!

Will the fix be available in earlier FF versions or the ESR version too?

@whimboo
Copy link
Collaborator

whimboo commented Jun 20, 2017

Good to hear that. We will discuss a possible uplift to 55 at least. Not sure if it is that easy for 52ESR but we will see. Please follow the bug for updates. Thanks.

@lock
Copy link

lock bot commented Aug 17, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants