diff mbox series

[1/2] toaster/tests: Add and use wait_until_element_visible()

Message ID 20260828213336.2038983-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 3e63c225d8e107526c4b4c8ccb5a85720c665ca1
Headers show
Series [1/2] toaster/tests: Add and use wait_until_element_visible() | expand

Commit Message

Richard Purdie Aug. 28, 2026, 9:33 p.m. UTC
In this test case there are multiple elements matching the selector so the
usual wait function isn't effective. Switch to waiting on the element directly,
adding a new function to allow us to do so.

This function is probably needed in other unreliable places in the tests too.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/toaster/tests/browser/selenium_helpers_base.py  | 7 +++++++
 lib/toaster/tests/browser/test_layerdetails_page.py | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/toaster/tests/browser/selenium_helpers_base.py b/lib/toaster/tests/browser/selenium_helpers_base.py
index 6953541ab55..a901791aa16 100644
--- a/lib/toaster/tests/browser/selenium_helpers_base.py
+++ b/lib/toaster/tests/browser/selenium_helpers_base.py
@@ -218,6 +218,13 @@  class SeleniumTestCaseBase(unittest.TestCase):
         element = Wait(self.driver, timeout=timeout).until(is_present, msg)
         return element
 
+    def wait_until_element_visible(self, element, timeout=Wait._TIMEOUT):
+        """ Wait until element matching CSS selector is visible on the page """
+        is_visible = lambda driver: element.is_displayed()
+        msg = 'An element should be visible'
+        Wait(self.driver, timeout=timeout).until(is_visible, msg)
+        return
+
     def wait_until_visible(self, selector, timeout=Wait._TIMEOUT):
         """ Wait until element matching CSS selector is visible on the page """
         is_visible = lambda driver: self.find(selector).is_displayed()
diff --git a/lib/toaster/tests/browser/test_layerdetails_page.py b/lib/toaster/tests/browser/test_layerdetails_page.py
index 6abfdef6999..0b45ca6e0f1 100644
--- a/lib/toaster/tests/browser/test_layerdetails_page.py
+++ b/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_clickable("#layer-git input[type=text]")
+            self.wait_until_element_visible(inputs)
             inputs.send_keys("-edited")
 
         # Save the new values