diff mbox series

[15/28] toaster/tests/browser/helpers: Add not visible wait function

Message ID 20241023095949.3351980-15-richard.purdie@linuxfoundation.org
State New
Headers show
Series [01/28] toaster/test/functional: Move _create_test_new_project to base class as helper | expand

Commit Message

Richard Purdie Oct. 23, 2024, 9:59 a.m. UTC
In some cases we want to wait until some element is not visible.
Add such a function helper.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/toaster/tests/browser/selenium_helpers_base.py | 7 +++++++
 1 file changed, 7 insertions(+)
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 5a4a4ef8b4..b664166055 100644
--- a/lib/toaster/tests/browser/selenium_helpers_base.py
+++ b/lib/toaster/tests/browser/selenium_helpers_base.py
@@ -227,6 +227,13 @@  class SeleniumTestCaseBase(unittest.TestCase):
         Wait(self.driver, poll=poll).until(is_visible, msg)
         return self.find(selector)
 
+    def wait_until_not_visible(self, selector, timeout=Wait._TIMEOUT):
+        """ Wait until element matching CSS selector is not visible on the page """
+        is_visible = lambda driver: self.find(selector).is_displayed()
+        msg = 'An element matching "%s" should be visible' % selector
+        Wait(self.driver, timeout=timeout).until_not(is_visible, msg)
+        return self.find(selector)
+
     def wait_until_clickable(self, selector, poll=1):
         """ Wait until element matching CSS selector is visible on the page """
         sel = selector