From 399a132bac77b5d24c89f9799022a61c0536e045 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 28 May 2020 09:29:40 -0700 Subject: [PATCH] tor: tests: functional: Fix to wait properly on progress page - Fix the condition for checking if we are on progress page by ensuring that the page is loaded fully before checking if it is that progress loader. Avoid a race condition writing a single atomic JS script to check both conditions. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/tests/functional/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 5a75812d9..0f3cf136e 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -184,7 +184,16 @@ def change_checkbox_status(browser, app_name, checkbox_id, def wait_for_config_update(browser, app_name): - while browser.is_element_present_by_css('.running-status.loading'): + """Wait until the configuration update progress goes away. + + Perform an atomic check that page is fully loaded and that progress icon is + not present at the same time to avoid race conditions due to automatic page + reloads. + + """ + script = 'return (document.readyState == "complete") && ' \ + '(!Boolean(document.querySelector(".running-status.loading")));' + while not browser.execute_script(script): time.sleep(0.1)