Using 0.63, I found that the locator block in Matchers's assert_text_present fails for me because it is not prefixed with self.
Code:
e = driver.find_element_by_tag_name('body')
assert text in e.text
Error:
File "/Library/Python/2.7/site-packages/py.saunter-0.63-py2.7.egg/saunter/matchers.py", line 345, in assert_text_present
e = driver.find_element_by_tag_name('body')
NameError: global name 'driver' is not defined
Fixing that to be ...
e = self.driver.find_element_by_tag_name('body')
... resolved that error, but something was odd in the timing because my test was passing yet my WebUI threw a handled exception in a popup, perhaps something timing related, but reproducible every time in pysaunter, but not when manually testing.
So, I modified the locator usage (and added some handling to raise an assertion error) with the following, and this works for me every time.
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))
Using 0.63, I found that the locator block in Matchers's assert_text_present fails for me because it is not prefixed with self.
Code: e = driver.find_element_by_tag_name('body') assert text in e.text
Error: File "/Library/Python/2.7/site-packages/py.saunter-0.63-py2.7.egg/saunter/matchers.py", line 345, in assert_text_present e = driver.find_element_by_tag_name('body') NameError: global name 'driver' is not defined
Fixing that to be ... e = self.driver.find_element_by_tag_name('body')
... resolved that error, but something was odd in the timing because my test was passing yet my WebUI threw a handled exception in a popup, perhaps something timing related, but reproducible every time in pysaunter, but not when manually testing.
So, I modified the locator usage (and added some handling to raise an assertion error) with the following, and this works for me every time.