From 56a8e5283e4e53ee108f91bf92843a30740c3a6e Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 22 Oct 2024 13:40:35 +0100 Subject: [PATCH] bitbake: toaster/tests/browser/helper: Add wait for jquery to complete 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. (Bitbake rev: 0eb206b355248e2a874a62baec30025652f2a5a8) Signed-off-by: Richard Purdie --- bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index 4eea2267cc..6953541ab5 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/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)