From dd14fac826003eabd8e875a9877b840192f673e0 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 22 Oct 2024 13:31:16 +0100 Subject: bitbake: toaster/tests/browser/helper: Improve wait_until_clickable exception handling Our own Wait() class allows exception handling which this form of wrapper does not. Switch the code to use our Wait() class to allow retrying upon encountering those exceptions (such as an element not being present yet). The displayed and visible test is what Selenium would be doing internally, there is no JS reprensetation of clickable directly. (Bitbake rev: 8266a01b750b3758badeee8fb3a1acfa72c17a93) Signed-off-by: Richard Purdie --- bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index 45eabaf1ce..82defea0f2 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py @@ -234,17 +234,9 @@ class SeleniumTestCaseBase(unittest.TestCase): def wait_until_clickable(self, selector, timeout=Wait._TIMEOUT): """ Wait until element matching CSS selector is visible on the page """ - sel = selector - if sel.startswith('#'): - sel = selector[1:] - WebDriverWait( - self.driver, - timeout=timeout, - ).until( - EC.element_to_be_clickable((By.ID, sel - ) - ) - ) + 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) return self.find(selector) def wait_until_focused(self, selector): -- cgit v1.2.3-54-g00ecf