diff mbox series

[25/28] toaster/tests/browser/helper: Add wait for jquery to complete

Message ID 20241023095949.3351980-25-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
Most of the tests that click on buttons need the DOM to stablise, including
any running JQuery code before the test can proceed. Add calls to do this
whenever we're about to click on an element.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/toaster/tests/browser/selenium_helpers_base.py | 2 ++
 1 file changed, 2 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 4eea2267cc..6953541ab5 100644
--- a/lib/toaster/tests/browser/selenium_helpers_base.py
+++ b/lib/toaster/tests/browser/selenium_helpers_base.py
@@ -234,6 +234,7 @@  class SeleniumTestCaseBase(unittest.TestCase):
 
     def wait_until_clickable(self, selector, timeout=Wait._TIMEOUT):
         """ Wait until element matching CSS selector is visible on the page """
+        WebDriverWait(self.driver, timeout=timeout).until(lambda driver: self.driver.execute_script("return jQuery.active == 0"))
         is_clickable = lambda driver: (self.find(selector).is_displayed() and self.find(selector).is_enabled())
         msg = 'An element matching "%s" should be clickable' % selector
         Wait(self.driver, timeout=timeout).until(is_clickable, msg)
@@ -241,6 +242,7 @@  class SeleniumTestCaseBase(unittest.TestCase):
 
     def wait_until_element_clickable(self, finder, timeout=Wait._TIMEOUT):
         """ Wait until element is clickable """
+        WebDriverWait(self.driver, timeout=timeout).until(lambda driver: self.driver.execute_script("return jQuery.active == 0"))
         is_clickable = lambda driver: (finder(driver).is_displayed() and finder(driver).is_enabled())
         msg = 'A matching element never became be clickable'
         Wait(self.driver, timeout=timeout).until(is_clickable, msg)