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 <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2024-10-22 13:31:16 +01:00
parent 7671fdcaf6
commit dd14fac826

View File

@@ -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):