@@ -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):
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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- lib/toaster/tests/browser/selenium_helpers_base.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)