From d9972cb3490a2a4a7e8b0fbfdf2a8699c00427f8 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 18 Dec 2024 20:09:50 -0500 Subject: [PATCH] tests: Work around an intermittent -t=auto failure. The 'Edit Profile' click is getting lost as things rapidly update? I haven't ever seen it as a human clicking. --- tools/autotest.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/autotest.py b/tools/autotest.py index 04f11542..00160cd3 100755 --- a/tools/autotest.py +++ b/tools/autotest.py @@ -16,8 +16,9 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.ui import WebDriverWait -def select(driver, path, action = None): +def select(driver, path, action = None, keep_trying = False): start_time = time.time() + done = False while True: try: driver.switch_to.default_content() @@ -47,13 +48,17 @@ def select(driver, path, action = None): context.clear() else: raise RuntimeError(f'Unexpected action: {action}.') - break + done = True + if not keep_trying: + break else: return context except (selenium.common.exceptions.NoSuchElementException, selenium.common.exceptions.NoSuchShadowRootException, selenium.common.exceptions.StaleElementReferenceException, selenium.common.exceptions.WebDriverException): + if done and keep_trying: + break if time.time() - start_time < 5.0: time.sleep(0.1) pass @@ -99,7 +104,7 @@ try: select(driver, ['tf-navigation', 'shadow_root', '#identity'], ('click',)) select(driver, ['tf-navigation', 'shadow_root', '#id_dropdown', '//button[position()=2]'], ('click',)) - select(driver, ['#document', 'frame', 'tf-app', 'shadow_root', '#tf-tab-news', 'shadow_root', '.tf-profile', 'shadow_root', '#edit_profile'], ('click',)) + select(driver, ['#document', 'frame', 'tf-app', 'shadow_root', '#tf-tab-news', 'shadow_root', '.tf-profile', 'shadow_root', '#edit_profile'], ('click',), keep_trying = True) select(driver, ['#document', 'frame', 'tf-app', 'shadow_root', '#tf-tab-news', 'shadow_root', '.tf-profile', 'shadow_root', '#name'], ('send_keys', 'user')) select(driver, ['#document', 'frame', 'tf-app', 'shadow_root', '#tf-tab-news', 'shadow_root', '.tf-profile', 'shadow_root', '#save_profile'], ('click',))