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
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
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.
Comments and activity
- Microsoft Edge Team
Changed Assigned To to “Brad E.”
Changed Assigned To to “Christian F.”
Changed Assigned To to “Mara P.”
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.
- Microsoft Edge Team
Changed Assigned To from “Mara P.” to “Clay M.”
Changed Status to “Confirmed”
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.
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.