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
{{ message }}
Repository navigation
select window handling needs some improvement #340
In short. Select window (or any other keyword that is trying to select window ) will fail if window that is focused will be closed before window focus is changed to other window. Same case will happen with Capture Screenshot keyword where it is not able to find the window and will fail.
My suggestions are:
a) another parameter for select window - to select the main window automatically if the last active window is not open anymore to avoid cases where same action can be fail case / bug.
b) create new select window keyword where a) parameter is used as default action.
NoSuchWindowException will be received if a test selects window right after a 'close window' call, if name/title prefix was given to select window which will lead to call _select_matching() -> get_current_window_handle().the root cause is that browser.get_current_window_handle() will fail after browser.close(). This reason can be found in '6.4 Close Window' section from http://www.w3.org/TR/webdriver/#defining-window-and-frame
6.4 Close Window
The close command closes the window that commands are currently being sent to. If this means that a call to get the list of window handles would return an empty list, then this close command must be the equivalent of calling "quit". That is, if the final window of a session is closed, then the session quits.
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.
so, the fix should pass this exception and skip ' browser.switch_to_window(starting_handle)' if catched:
However, other function in the future could suffer same issue from close_window(). Since people often want to return previous window when close a popup window, it would be better to let close_window() to do browser.switch_to_window(browser.get_window_handles()[-1]):
defclose_window(self):
"""Closes currently opened pop-up window."""self._current_browser().close()
handles=self._current_browser().get_window_handles()
iflen(handles) >=1:
self._current_browser().switch_to_window(handles[-1])
There has not been activity for this issue for long time and we are planning to close the old issues if they are not anymore valid ones. If you feel that this is still valid issue, could you send an update. If update is not received in a month, we will assume that this is not anymore an issues and we will close this issue.
Activity
divfor commentedon May 10, 2015
===from windowmanager.py =======
def _select_matching(self, browser, matcher, error):
starting_handle = browser.get_current_window_handle()
for handle in browser.get_window_handles():
browser.switch_to_window(handle)
if matcher(browser.get_current_window_info()):
return
browser.switch_to_window(starting_handle)
raise ValueError(error)
======change to======
def _select_matching(self, browser, matcher, error):
try:
starting_handle = browser.get_current_window_handle()
except NoSuchWindowException:
starting_handle = None
pass
for handle in browser.get_window_handles():
browser.switch_to_window(handle)
if matcher(browser.get_current_window_info()):
return
if starting_handle is not None:
browser.switch_to_window(starting_handle)
raise ValueError(error)
just-be-dev commentedon May 10, 2015
@divfor, thanks for narrowing this down more. I'm on vacation, but I'll try to address this tomorrow sometime.
divfor commentedon May 11, 2015
NoSuchWindowException will be received if a test selects window right after a 'close window' call, if name/title prefix was given to select window which will lead to call _select_matching() -> get_current_window_handle().the root cause is that browser.get_current_window_handle() will fail after browser.close(). This reason can be found in '6.4 Close Window' section from http://www.w3.org/TR/webdriver/#defining-window-and-frame
so, the fix should pass this exception and skip ' browser.switch_to_window(starting_handle)' if catched:
However, other function in the future could suffer same issue from close_window(). Since people often want to return previous window when close a popup window, it would be better to let close_window() to do browser.switch_to_window(browser.get_window_handles()[-1]):
divfor commentedon May 11, 2015
As for enhancement ‘Select Window’, I have raised a PR #395
aaltat commentedon May 23, 2016
There has not been activity for this issue for long time and we are planning to close the old issues if they are not anymore valid ones. If you feel that this is still valid issue, could you send an update. If update is not received in a month, we will assume that this is not anymore an issues and we will close this issue.
aaltat commentedon Nov 2, 2017
We made improvements as part of #968. Please retest with the code in master.
aaltat commentedon Aug 21, 2018
Closing due inactivity.