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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2020-05-28 09:29:40 -07:00 committed by James Valleroy
parent ae73b296de
commit 399a132bac
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -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)