From 4c6a2323d90e9321ec2b78e226167b3013ea69ab Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Sat, 29 Jan 2022 00:03:51 +0100 Subject: make Haketilo buildable again (for Mozilla) How cool it is to throw away 5755 lines of code... --- test/unit/test_repo_query_cacher.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'test/unit/test_repo_query_cacher.py') 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({ -- cgit v1.2.3