Skip to content

Commit e00a86c

Browse files
committed
Throw clearer error if no new window handles found
1 parent df8a548 commit e00a86c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

notebook/tests/selenium/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,11 @@ def new_window(browser, selector=None):
324324
"""
325325
initial_window_handles = browser.window_handles
326326
yield
327-
new_window_handle = next(window for window in browser.window_handles
328-
if window not in initial_window_handles)
329-
browser.switch_to.window(new_window_handle)
327+
new_window_handles = [window for window in browser.window_handles
328+
if window not in initial_window_handles]
329+
if not new_window_handles:
330+
raise Exception("No new windows opened during context")
331+
browser.switch_to.window(new_window_handles[0])
330332
if selector is not None:
331333
wait_for_selector(browser, selector)
332334

0 commit comments

Comments
 (0)