From 2d5d96ae331b896ab4aae4418f2583ead3f5e547 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Thu, 30 May 2024 18:27:29 +0200 Subject: [PATCH] ci(ui-tests): retry getting element by xpath --- scripts/ui-tests/dashboard_test.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/ui-tests/dashboard_test.py b/scripts/ui-tests/dashboard_test.py index 602d944fd..85d40cec8 100644 --- a/scripts/ui-tests/dashboard_test.py +++ b/scripts/ui-tests/dashboard_test.py @@ -100,7 +100,15 @@ def test_docs_link(driver, login, dashboard_url): driver.get(dest_url) ensure_current_url(driver, dest_url) xpath_link_help = "//div[@id='app']//div[@class='nav-header']//a[contains(@class, 'link-help')]" - link_help = driver.find_element(By.XPATH, xpath_link_help) + # retry up to 5 times + for _ in range(5): + try: + link_help = driver.find_element(By.XPATH, xpath_link_help) + break + except NoSuchElementException: + time.sleep(1) + else: + raise AssertionError("Cannot find the help link") driver.execute_script("arguments[0].click();", link_help) prefix, emqx_version = fetch_version(dashboard_url)