Permalink
Browse files

use is_element_visible instead of try except

  • Loading branch information...
1 parent 6e3f172 commit 37e7efbce55baaf2c032f5ef84fa4834d0dfbbd5 @klrmn klrmn committed Mar 30, 2012
Showing with 3 additions and 8 deletions.
  1. +3 −8 pages/desktop/login_page.py
@@ -42,12 +42,7 @@ def log_in(self, user='default'):
self.selenium.find_element(*self._password_box_locator).send_keys(credentials['password'])
self.selenium.find_element(*self._log_in_button_locator).click()
- error = ""
- try:
+ if self.is_element_visible(*self._login_error_locator):
error = self.selenium.find_element(*self._login_error_locator).text
- except NoSuchElementException, ElementNotVisibleException:
- '''no error, do nothing'''
- finally:
- if error != "":
- error = "login failed for %s\n" % credentials['name'] + error
- Assert.fail(error)
+ error = "login failed for %s\n" % credentials['name'] + error
+ Assert.fail(error)

0 comments on commit 37e7efb

Please sign in to comment.