[PATCH] toaster/test: Setup delay after drvier action self.get(url)
Alassane Yattara <[email protected]> Mon, 8 Jan 2024 22:09:58 +0100
| Newsgroups | org.yoctoproject.lists.toaster |
|---|---|
| Message-ID | <[email protected]> |
Recurring test failures result from insufficient delays in driver actions= . Signed-off-by: Alassane Yattara <[email protected]> --- lib/toaster/tests/browser/selenium_helpers_base.py | 7 +++++++ lib/toaster/tests/browser/test_all_builds_page.py | 4 +++- lib/toaster/tests/browser/test_builddashboard_page.py | 1 + lib/toaster/tests/browser/test_new_custom_image_page.py | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/toaster/tests/browser/selenium_helpers_base.py b/lib/toa= ster/tests/browser/selenium_helpers_base.py index 562fedec..393be754 100644 --- a/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/lib/toaster/tests/browser/selenium_helpers_base.py @@ -182,6 +182,13 @@ class SeleniumTestCaseBase(unittest.TestCase): abs_url =3D '%s%s' % (self.live_server_url, url) self.driver.get(abs_url) =20 + try: # Ensure page is loaded before proceeding + self.wait_until_visible("#global-nav", poll=3D3) + except NoSuchElementException: + self.driver.implicitly_wait(3) + except TimeoutException: + self.driver.implicitly_wait(3) + def find(self, selector): """ Find single element by CSS selector """ return self.driver.find_element(By.CSS_SELECTOR, selector) diff --git a/lib/toaster/tests/browser/test_all_builds_page.py b/lib/toas= ter/tests/browser/test_all_builds_page.py index 7019b3db..ab6da821 100644 --- a/lib/toaster/tests/browser/test_all_builds_page.py +++ b/lib/toaster/tests/browser/test_all_builds_page.py @@ -224,6 +224,7 @@ class TestAllBuildsPage(SeleniumTestCase): =20 url =3D reverse('all-builds') self.get(url) + self.wait_until_visible('#allbuildstable', poll=3D3) =20 # get the project name cells from the table cells =3D self.find_all('#allbuildstable td[class=3D"project"]') @@ -232,7 +233,7 @@ class TestAllBuildsPage(SeleniumTestCase): =20 for cell in cells: content =3D cell.get_attribute('innerHTML') - help_icons =3D cell.find_elements_by_css_selector(selector) + help_icons =3D cell.find_elements(By.CSS_SELECTOR, selector) =20 if re.search(self.PROJECT_NAME, content): # no help icon next to non-cli project name @@ -256,6 +257,7 @@ class TestAllBuildsPage(SeleniumTestCase): =20 url =3D reverse('all-builds') self.get(url) + self.wait_until_visible('#allbuildstable', poll=3D3) =20 # test recent builds area for successful build element =3D self._get_build_time_element(build1) diff --git a/lib/toaster/tests/browser/test_builddashboard_page.py b/lib/= toaster/tests/browser/test_builddashboard_page.py index b713f300..d838ce36 100644 --- a/lib/toaster/tests/browser/test_builddashboard_page.py +++ b/lib/toaster/tests/browser/test_builddashboard_page.py @@ -162,6 +162,7 @@ class TestBuildDashboardPage(SeleniumTestCase): """ url =3D reverse('builddashboard', args=3D(build.id,)) self.get(url) + self.wait_until_visible('#global-nav', poll=3D3) =20 def _get_build_dashboard_errors(self, build): """ diff --git a/lib/toaster/tests/browser/test_new_custom_image_page.py b/li= b/toaster/tests/browser/test_new_custom_image_page.py index 4ad22c7a..9f0b6397 100644 --- a/lib/toaster/tests/browser/test_new_custom_image_page.py +++ b/lib/toaster/tests/browser/test_new_custom_image_page.py @@ -90,6 +90,7 @@ class TestNewCustomImagePage(SeleniumTestCase): """ url =3D reverse('newcustomimage', args=3D(self.project.id,)) self.get(url) + self.wait_until_visible('#global-nav', poll=3D3) =20 self.click('button[data-recipe=3D"%s"]' % self.recipe.id) =20 --=20 2.34.1