diff --git a/saunter/matchers.py b/saunter/matchers.py index bb59ab8..f6fc48c 100644 --- a/saunter/matchers.py +++ b/saunter/matchers.py @@ -337,8 +337,15 @@ def assert_text_present(self, text, msg=None): :params text: the string to search for :params msg: (Optional) msg explaining the difference """ - e = driver.find_element_by_tag_name('body') - assert text in e.text + 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): """