Pyccuracy is a BDD-style Web Acceptance Testing framework in Python.
I'm testing a Python application using pyccuracy, which has a selenium driver.
My test results are presenting some instability issues with xPaths. Sometimes I get an Invalid xPath error, with a valid xPath. If I run the test again, it may work. I've follow the stacktrace but I couldn't find a solution for that.
Stacktrace:
I do not see "top-search-tag-name" element - FAILED - Error executing action <bound method ElementIsNotVisibleAction.execute of <pyccuracy.actions.core.element_actions.ElementIsNotVisibleAction object at 0x2283b10>> - Traceback (most recent call last):
File "/workspace/env_test/local/lib/python2.7/site-packages/pyccuracy/fixture_items.py", line 99, in execute
self.execute_function(context, *self.args, **self.kwargs)
File "/workspace/env_test/local/lib/python2.7/site-packages/pyccuracy/actions/core/element_actions.py", line 179, in execute
self.assert_element_is_not_visible(context, element_key, error_message)
File "/workspace/env_test/local/lib/python2.7/site-packages/pyccuracy/actions/__init__.py", line 147, in assert_element_is_not_visible
if self.is_element_visible(context, selector):
File "/workspace/env_test/local/lib/python2.7/site-packages/pyccuracy/actions/__init__.py", line 139, in is_element_visible
is_visible = context.browser_driver.is_element_visible(selector)
File "/workspace/env_test/local/lib/python2.7/site-packages/pyccuracy/drivers/core/selenium_driver.py", line 86, in is_element_visible
is_present = self.selenium.is_element_present(element_selector)
File "/workspace/env_test/local/lib/python2.7/site-packages/selenium/selenium.py", line 1369, in is_element_present
return self.get_boolean("isElementPresent", [locator,])
File "/workspace/env_test/local/lib/python2.7/site-packages/selenium/selenium.py", line 261, in get_boolean
boolstr = self.get_string(verb, args)
File "/workspace/env_test/local/lib/python2.7/site-packages/selenium/selenium.py", line 223, in get_string
result = self.do_command(verb, args)
File "/workspace/env_test/local/lib/python2.7/site-packages/selenium/selenium.py", line 217, in do_command
raise Exception, data
Exception: ERROR: Invalid xpath [2]: //form[@id='searchtop']//ul[@class = 'tags block editing']//li/a[@class = 'tag']
HTML Code (cleaned up)
<form id="searchtop">
<ul class="tags block editing">
<li class="tag">
<a rel='nofollow' href="#" class="tag">Section Label</a>
<a rel='nofollow' href="#" class="remove" title="Remove filter"></a>
</li>
</ul>
...
</form>
In this test I've clicked the remove filter link and then checked if the element is not present. The xPath is correct. In Chrome, for instance, I get the element selected with $x(...), before removing the tag, and get an empty list after removing it. Which is what the test does. Sometimes the same test runs without errors, in the exact same enviroment.
Ideas?
Source: (StackOverflow)