I am running a selenium test with python. I am having a specific problem with the following bit of html code.
<span class="cke_label" id="cke_8_label">Source</span>
I have tried the following:
self.assert_element_present_by_class('Source button', 'cke_8_label', 'cke_label')**
here's the function:
def assert_element_present_by_class(self, description, id, name):
sel = self.selenium
try:
self.assert_(sel.is_element_present("//" + id + "[contains(@class,'" + name + "')]"))
logging.info('PASS: "' + description + '" is present')
except Exception:
logging.exception('FAIL: "' + description + '" is not present')
This gives me this error.......
File "Template_Designer_P37.py", line 293, in assert_element_present_by_class self.assert_(sel.is_element_present("//" + id + "[contains(@class,'" + name + "')]")) File "C:\Python27\lib\unittest\case.py", line 420, in assertTrue raise self.failureException(msg) AssertionError: False is not true
I have tried a couple of other methods, such as simply trying to assert that the id exists.
My hunch is that the problem surrounds the 'id'.
Any thoughts?
self.assert_(self.sel.is_element_present("//*[@id='" + id + "' and contains(@class,'" + name + "')]"))