From 314ffc0bc5b0af79a5ed7938634644c1a9e6fa4e Mon Sep 17 00:00:00 2001 From: Serhii Tsymbaliuk Date: Sun, 2 Feb 2020 20:17:44 +0100 Subject: [PATCH] WebUI tests: Fix 'Button is not displayed' exception 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 --- ipatests/test_webui/ui_driver.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index baa0b2e9b67..299844e8ad0 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -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()