From 524bbe060e9db2b62f4a18eda9bc4d820c427386 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 22 Oct 2024 13:33:18 +0100 Subject: bitbake: toaster/tests/browser: Add various fixes for test failures encountered Fixes for the browser tests which: * Add/improve waiting for specific elements * Waiting for elements to be interactable, not just visible * Hiding notification windows * Using more specific asserts to obtain improved error messages (Bitbake rev: 0c3f9bc2b9516d2af391f2e081280eb7fa62a05e) Signed-off-by: Richard Purdie --- bitbake/lib/toaster/tests/browser/test_all_builds_page.py | 1 + bitbake/lib/toaster/tests/browser/test_landing_page.py | 1 + bitbake/lib/toaster/tests/browser/test_layerdetails_page.py | 12 +++++++++--- bitbake/lib/toaster/tests/browser/test_new_project_page.py | 6 ++---- 4 files changed, 13 insertions(+), 7 deletions(-) (limited to 'bitbake/lib/toaster/tests') diff --git a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py index a1f8057113..9ab81fb11b 100644 --- a/bitbake/lib/toaster/tests/browser/test_all_builds_page.py +++ b/bitbake/lib/toaster/tests/browser/test_all_builds_page.py @@ -200,6 +200,7 @@ class TestAllBuildsPage(SeleniumTestCase): # should see a rebuild button for non-command-line builds self.wait_until_visible('#allbuildstable tbody tr') + self.wait_until_visible('.rebuild-btn') selector = 'div[data-latest-build-result="%s"] .rebuild-btn' % build1.id run_again_button = self.find_all(selector) self.assertEqual(len(run_again_button), 1, diff --git a/bitbake/lib/toaster/tests/browser/test_landing_page.py b/bitbake/lib/toaster/tests/browser/test_landing_page.py index f3300430ba..210359d561 100644 --- a/bitbake/lib/toaster/tests/browser/test_landing_page.py +++ b/bitbake/lib/toaster/tests/browser/test_landing_page.py @@ -44,6 +44,7 @@ class TestLandingPage(SeleniumTestCase): # and info modal is appearing when clicking on the info sign info_sign.click() # click on the info sign make attribute 'aria-describedby' visible info_model_id = info_sign.get_attribute('aria-describedby') + self.wait_until_visible(f'#{info_model_id}') info_modal = self.find(f'#{info_model_id}') self.assertTrue(info_modal.is_displayed()) self.assertTrue("Toaster version information" in info_modal.text) diff --git a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py index c4f3f79d34..a6d1bc46c2 100644 --- a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py +++ b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py @@ -100,7 +100,7 @@ class TestLayerDetailsPage(SeleniumTestCase): (self.initial_values, value)) # Make sure the input visible beofre sending keys - self.wait_until_visible("#layer-git input[type=text]") + self.wait_until_clickable("#layer-git input[type=text]") inputs.send_keys("-edited") # Save the new values @@ -211,6 +211,7 @@ class TestLayerDetailsPage(SeleniumTestCase): self.get(self.url) # Add the layer + self.wait_until_clickable("#add-remove-layer-btn") self.click("#add-remove-layer-btn") notification = self.wait_until_visible("#change-notification-msg") @@ -218,12 +219,17 @@ class TestLayerDetailsPage(SeleniumTestCase): expected_text = "You have added 1 layer to your project: %s" % \ self.imported_layer_version.layer.name - self.assertTrue(expected_text in notification.text, + self.assertIn(expected_text, notification.text, "Expected notification text %s not found was " " \"%s\" instead" % (expected_text, notification.text)) + hide_button = self.find('#hide-alert') + hide_button.click() + self.wait_until_not_visible('#change-notification') + # Remove the layer + self.wait_until_clickable("#add-remove-layer-btn") self.click("#add-remove-layer-btn") notification = self.wait_until_visible("#change-notification-msg") @@ -231,7 +237,7 @@ class TestLayerDetailsPage(SeleniumTestCase): expected_text = "You have removed 1 layer from your project: %s" % \ self.imported_layer_version.layer.name - self.assertTrue(expected_text in notification.text, + self.assertIn(expected_text, notification.text, "Expected notification text %s not found was " " \"%s\" instead" % (expected_text, notification.text)) diff --git a/bitbake/lib/toaster/tests/browser/test_new_project_page.py b/bitbake/lib/toaster/tests/browser/test_new_project_page.py index b6187db105..e50f236c32 100644 --- a/bitbake/lib/toaster/tests/browser/test_new_project_page.py +++ b/bitbake/lib/toaster/tests/browser/test_new_project_page.py @@ -89,12 +89,10 @@ class TestNewProjectPage(SeleniumTestCase): radio = self.driver.find_element(By.ID, 'type-new') radio.click() - self.click("#create-project-button") - - self.wait_until_present('#hint-error-project-name') + self.wait_until_visible('#hint-error-project-name') element = self.find('#hint-error-project-name') - self.assertTrue(("Project names must be unique" in element.text), + self.assertIn("Project names must be unique", element.text, "Did not find unique project name error message") # Try and click it anyway, if it submits we'll have a new project in -- cgit v1.2.3-54-g00ecf