Skip to content

Commit

Permalink
WebUI tests: Fix 'Button is not displayed' exception
Browse files Browse the repository at this point in the history
Add a small timeout (up to 5 seconds) which allows to prevent exceptions when
WebDriver attempts to click a button before it is rendered.

Ticket: https://pagure.io/freeipa/issue/8169

Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
  • Loading branch information
serg-cymbaluk committed Feb 4, 2020
1 parent c940f96 commit 314ffc0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ipatests/test_webui/ui_driver.py
Expand Up @@ -731,9 +731,16 @@ def button_click(self, name, parent=None,

def _button_click(self, selector, parent, name=''):
btn = self.find(selector, By.CSS_SELECTOR, parent, strict=True)

# The small timeout (up to 5 seconds) allows to prevent exceptions when
# driver attempts to click a button before it is rendered.
WebDriverWait(self.driver, 5, 0.2).until(
lambda d: btn.is_displayed(),
'Button is not displayed: %s' % (name or selector)
)
self.move_to_element_in_page(btn)

disabled = btn.get_attribute("disabled")
assert btn.is_displayed(), 'Button is not displayed: %s' % name
assert not disabled, 'Invalid button state: disabled. Button: %s' % name
btn.click()
self.wait_for_request()
Expand Down

0 comments on commit 314ffc0

Please sign in to comment.