You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you close a pop-up window using close window, all further Selenium2 keywords fail with an exception:
NoSuchWindowException: Message: Window not found. The browser window may have been closed.
Even keywords as "get window names" fail.
The same problem arises when the pop-up window is closed by mouse click or using Javascript window.close().
Minimal set-up for testing: Simple local html file with
click me
And a simple Robot test with
Open browser test.html
Click button bt1
${windows}= Get Window Names
select window cc
sleep 1s
close window
${windows}= Get Window Names
A "sleep" or "wait until keyword succeeds" after "close window" does not help.
This is not a Selenium issue. If you code the scenario (open and close a pop-up window) in Java and the Java API for Selenium, everything works fine. No exceptions arise.
Set-ups:
OS: Mac OS 10.10 and Windows 7
Browsers: Firefox, Chrome, IE10
Selenium 2.44
Selenium2Library 1.6, 1.5, 1.4
fromseleniumimportwebdriverdriver=webdriver.Firefox()
driver.get('file:///home/user/test_win_operation/test.html')
el=driver.find_element_by_id('bt1')
el.click()
h=driver.window_handlesdriver.current_window_handle# assuming second windowdriver.switch_to.window(h[1])
driver.close()
driver.window_handlesdriver.quit()
but do see the issue with the library (1.6)
*** Settings ***Library Selenium2Library
#Test Teardown Close All Browsers*** Test Cases ***Check window issue
Open browser file:///home/user/test_win_operation/test.html
Click button bt1
${windows}= Get Window Names
Select Window cc
Close Window
${windows}= Get Window Names
Just looking into the backlog of issues for any other open/close/switch window related ones. Noting (in no particular order) #205, #340, #213. Not sure if these still valid. Please feel free to add any I have missed. Maybe we can tackle these altogether.
This issue is due to call keyword with 'browser.get_current_window_handle()' right after call 'close window' which will not change current window handle to something else.
The window management keywords have been refactored as part of #968. Therefore I am closing the issue. If problem is still present, please send an update on the issue.
Activity
emanlove commentedon Feb 11, 2015
Trying Python Selenium on
OS: Linux Ubuntu 14.04
Browsers: Firefox 31.0
Selenium 2.44
Selenium2Library 1.6
Using the test page, test.html
I have no issues with just selenium
but do see the issue with the library (1.6)
emanlove commentedon Feb 11, 2015
Just looking into the backlog of issues for any other open/close/switch window related ones. Noting (in no particular order) #205, #340, #213. Not sure if these still valid. Please feel free to add any I have missed. Maybe we can tackle these altogether.
divfor commentedon May 10, 2015
This issue is due to call keyword with 'browser.get_current_window_handle()' right after call 'close window' which will not change current window handle to something else.
see 6.4 in http://www.w3.org/TR/webdriver/#defining-window-and-frame
Once the window has closed, future commands must return a status code of no such window until a new window is selected for receiving commands.
aaltat commentedon Nov 2, 2017
The window management keywords have been refactored as part of #968. Therefore I am closing the issue. If problem is still present, please send an update on the issue.