diff options
Diffstat (limited to 'test/unit/test_repo_query_cacher.py')
-rw-r--r-- | test/unit/test_repo_query_cacher.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/unit/test_repo_query_cacher.py b/test/unit/test_repo_query_cacher.py index b1ce4c8..5fbc5cd 100644 --- a/test/unit/test_repo_query_cacher.py +++ b/test/unit/test_repo_query_cacher.py @@ -65,18 +65,19 @@ def run_content_script_in_new_window(driver, url): Open the provided url in a new tab, find its tab id and return it, with current window changed back to the initial one. """ - initial_handle = driver.current_window_handle - handles = driver.window_handles + handle0 = driver.current_window_handle + initial_handles = [*driver.window_handles] driver.execute_script('window.open(arguments[0], "_blank");', url) - WebDriverWait(driver, 10).until(lambda d: d.window_handles is not handles) - new_handle = [h for h in driver.window_handles if h not in handles][0] + window_added = lambda d: set(d.window_handles) != set(initial_handles) + WebDriverWait(driver, 10).until(window_added) + new_handle = [*set(driver.window_handles).difference(initial_handles)][0] driver.switch_to.window(new_handle) get_tab_id = lambda d: d.execute_script('return window.haketilo_tab;') tab_id = WebDriverWait(driver, 10).until(get_tab_id) - driver.switch_to.window(initial_handle) + driver.switch_to.window(handle0) return tab_id @pytest.mark.ext_data({ |