Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
webui selenium: fixes a bug in wait_and_click
  • Loading branch information
joergsteffens committed Jun 21, 2018
1 parent 9031afe commit 274c5c3
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests/selenium/webui-selenium-test.py
Expand Up @@ -394,7 +394,7 @@ def logout(self):
self.wait_and_click(By.LINK_TEXT, 'Logout')
sleep(self.sleeptime)

# Methods used for waiting and clicking
# Methods used for waiting and clicking

def wait_and_click(self, by, value, modal_by=None, modal_value=None):
logger = logging.getLogger()
Expand All @@ -411,24 +411,28 @@ def wait_and_click(self, by, value, modal_by=None, modal_value=None):
else:
logger.info('closing modal %s %s', modal_by, modal_value)
logger.info('waiting for %s %s (%ss)', by, value, seconds)
element = self.wait_for_element(by, value)

try:
element.click()
except WebDriverException as e:
logger.info('WebDriverException: %s', e)
sleep(self.waittime)
element = self.wait_for_element(by, value)
except ElementTimeoutException as e:
logger.info('ElementTimeoutException: %s', e)
sleep(self.waittime)
except ElementNotFoundException as e:
logger.info('ElementNotFoundException: %s', e)
sleep(self.waittime)
# The case where the element doesn't exist is handled in wait_for_element
# except NoSuchElementException as e:
# logger.info("NoSuchElementException while clicking: %s", e)
# sleep(self.waittime)
else:
return element

if element is not None:
try:
element.click()
except WebDriverException as e:
logger.info('WebDriverException: %s', e)
sleep(self.waittime)
# The case where the element doesn't exist is handled in wait_for_element
# except NoSuchElementException as e:
# logger.info("NoSuchElementException while clicking: %s", e)
# sleep(self.waittime)
else:
return element
seconds = (datetime.now() - starttime).total_seconds()
logger.error('failed to click %s %s', by, value)
raise FailedClickException(value)
Expand Down

0 comments on commit 274c5c3

Please sign in to comment.