Skip to content

Commit

Permalink
Fixes issue Element-34#50 for assert_text_present locator (minor corr…
Browse files Browse the repository at this point in the history
…ection)
  • Loading branch information
stevenerat committed Jan 29, 2014
1 parent 6251b52 commit e83dbcf
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions saunter/matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,15 @@ def assert_text_present(self, text, msg=None):
:params text: the string to search for
:params msg: (Optional) msg explaining the difference
"""
if isinstance(self.driver, tailored.remotecontrol.RemoteControl):
assert self.driver.is_text_present(text)
else:
try:
locator = ("xpath=//*[contains(text(), '%s')]") % text
self.driver.find_element_by_locator(locator)
return True
except:
if len(msg) == 0:
raise AssertionError('Text "%s" was not found.' % text)
else:
raise AssertionError('Text "%s" was not found. %s' % (text,msg))
try:
locator = ("xpath=//*[contains(text(), '%s')]") % text
self.driver.find_element_by_locator(locator)
return True
except:
if len(msg) == 0:
raise AssertionError('Text "%s" was not found.' % text)
else:
raise AssertionError('Text "%s" was not found. %s' % (text,msg))

def verify_text_present(self, text, msg=None):
"""
Expand Down

0 comments on commit e83dbcf

Please sign in to comment.