Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Release Notes

1.7 (unreleased)
----------------
- Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window'
will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same
issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'.
[divfor]

- Corrected error message in new keyword 'Wait Until Element Is Not
Visible' to reflect element being visible instead of not visible.
[joepurdy]
Expand Down
16 changes: 12 additions & 4 deletions src/Selenium2Library/locators/windowmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,28 @@ def _parse_locator(self, locator):

def _get_window_infos(self, browser):
window_infos = []
starting_handle = browser.get_current_window_handle()
try:
starting_handle = browser.get_current_window_handle()
except NoSuchWindowException:
starting_handle = None
try:
for handle in browser.get_window_handles():
browser.switch_to_window(handle)
window_infos.append(browser.get_current_window_info())
finally:
browser.switch_to_window(starting_handle)
if starting_handle:
browser.switch_to_window(starting_handle)
return window_infos

def _select_matching(self, browser, matcher, error):
starting_handle = browser.get_current_window_handle()
try:
starting_handle = browser.get_current_window_handle()
except NoSuchWindowException:
starting_handle = None
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)
if starting_handle:
browser.switch_to_window(starting_handle)
raise ValueError(error)
15 changes: 15 additions & 0 deletions test/acceptance/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ Get and Set Window Position
Should Be Equal ${position_x} ${returned_x}
Should Be Equal ${position_y} ${returned_y}

Select Window By Title After Close Window
Cannot Be Executed in IE
Open Popup Window, Select It And Verify myName
Close Popup Window And Select Main Window By Title

Get Window Titles After Close Window
[Tags] Known Issue - TravisCI
Cannot Be Executed in IE
Open Popup Window, Select It And Verify myName
Close Window
${titles}= Get Window Titles

*Keywords*
Open Popup Window, Select It And Verify
Expand All @@ -66,3 +77,7 @@ Select Main Window And Verify
Do Action In Popup Window And Verify
Click Link change title
Title Should Be Changed

Close Popup Window And Select Main Window By Title
Close Window
Select Window title=Click link to show a popup window