Can't close a window opened with JavaScript

Site Outreach Issue #8216991

Details

Author
Douglas S.
Created
Jul 19, 2016
Privacy
This issue is public.
Found in
  • Microsoft Edge
Standard affected
WebDriver

Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

  • Open a new window with WebDriver.execute_script("window.open()")
  • Switch to the new window using WebDriver.switch_to.window(WebDriver.window_handles[-1])
  • Attempt to close the new window using WebDriver.close()

When I attempt to close the window, I get the following exception:
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 510, in close
self.execute(Command.CLOSE)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: Selenium didn’t complete your last command on time.

This only seems to happen for Microsoft Edge; I don’t experience the issue for any other webdriver, including Firefox, Chrome, or even Internet Explorer drivers.

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Brad E.”

      Changed Assigned To to “Christian F.”

      Changed Assigned To to “Mara P.”

    • Hey Douglas,

      What version of Windows 10 and WebDriver are you using?

      For Windows 10 you can go to Start > Settings > System > About and grab the Build field.

      For WebDriver simply right-click the executable > Properties > Details and grab the File Version field.

      Thanks,
      Clay

    • Microsoft Edge Team

      Changed Assigned To from “Mara P.” to “Clay M.”

      Changed Status to “Confirmed”

      Changed Title from “Edge webdriver can't close a window opened with JavaScript” to “Edge webdriver can't close a window opened with JavaScript”

      Changed Title from “Edge webdriver can't close a window opened with JavaScript” to “Can't close a window opened with JavaScript”

      Changed Status from “Confirmed” to “Site Outreach”

    • After investigating this it seems to be an issue with the language binding. We definitely support the close command. My guess is that the way the array of Windows is handled using -1 as an index is causing trouble. Here is the test code I used to verify (note the language is different but the concept is the same). We definitely support the Close() command as per the W3C’s WebDriver specification.

      edgeDriver.Navigate().GoToUrl(“http://ie-snap/scratchtests/clmartin/test.html”);

      edgeDriver.ExecuteScript(“window.open();”);
      edgeDriver.SwitchTo().Window(edgeDriver.WindowHandles[1]);

      edgeDriver.Close();

      Note that after this code runs I’d need to swap back to the original window using SwitchTo as my driver is currently on the closed window now.

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

    Sign in