Skip to content

Commit 2f6a88a

Browse files
committed
stay at current if not found windows by default
1 parent 971bcaa commit 2f6a88a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Selenium2Library/locators/windowmanager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,19 @@ def _select_by_default(self, browser, criteria):
6464
handles = browser.get_window_handles()
6565
browser.switch_to_window(handles[0])
6666
return
67+
try:
68+
starting_handle = browser.get_current_window_handle()
69+
except NoSuchWindowException:
70+
starting_handle = None
6771
for handle in browser.get_window_handles():
6872
browser.switch_to_window(handle)
6973
if criteria == handle:
7074
return
7175
for item in browser.get_current_window_info()[2:4]:
7276
if item.strip().lower() == criteria.lower():
7377
return
78+
if starting_handle:
79+
browser.switch_to_window(starting_handle)
7480
raise ValueError("Unable to locate window with handle or name or title or URL '" + criteria + "'")
7581

7682
def _select_by_last_index(self, browser):

0 commit comments

Comments
 (0)