I am creating a Python script with Selenium. I want to run a specific test that checks the default text of a textbox when the page loads up. Below is my code…….
try:
self.assertEqual("Search by template name or category..", sel.get_text("//table[@id='pluginToolbarButton_forms']/tbody/tr[2]/td[2]/em"))
logging.info(' PASS: text box text is correct')
except Exception:
logging.exception(' FAIL: text box text is incorrect')
Here is my error……
self.assertEqual("Search by template name or category..", sel.get_text("//table[@id='pluginToolbarButton_forms']/tbody/tr[2]/td[2]/em"))
File "C:\Python27\lib\unittest\case.py", line 509, in assertEqual
assertion_func(first, second, msg=msg)
File "C:\Python27\lib\unittest\case.py", line 502, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 'Search by template name or category..' != u'Submitter Requests'
Am I using the wrong function?
Your
AssertionErrorstates that the assertion you tried (that’s theself.assertEqual(...)in your first code example) failed:This assertion explains that the string
'Search by template name or category'is different from'Submitter Requests', which is correct … the strings are, in fact, different.I would check your second parameter to
self.assertEqualand make sure that you’re selecting the right feature.