Note that there are some explanatory texts on larger screens.

plurals
  1. POSelenium syntax for Verifications that work with Hudson / jenkins
    text
    copied!<p>I've gone through various tutorials and Stack Overflow posts and understand that Selenium can output XML test results in a way that Hudson can read/report them in HTML format.</p> <p>What I don't understand is the syntax to use in Python, to get the results to look something like: Testcase_LoginPage.VerifyButton1Present <strong>fail</strong></p> <p>Testcase_LoginPage.VerifyButton2Present <strong>pass</strong></p> <p>Currently, when I drill down the results in Hudson, they won't be formatted in a useful way as I described above, and also it will report that it only ran ONE test, even though it ran multiple assert Tests:</p> <p>Traceback (most recent call last): File "D:\Temp\1TestingApps\Selenium\Scripts\SampleScripts\SamCodeSample\test\SOreports.py", line 22, in tearDown self.assertEqual([], self.verificationErrors) AssertionError: Lists differ: [] != ['Sign Up button issue2']</p> <p>Second list contains 1 additional elements. First extra element 0: Sign Up button issue2</p> <ul> <li>[]</li> <li>['Sign Up button issue2']</li> </ul> <p>Ran 1 test in 13.610s</p> <p>FAILED (errors=1)</p> <h2>Generating XML reports...</h2> <p>Code is below. Thanks in advance for the help!</p> <p>from selenium import selenium import unittest, xmlrunner, os, re</p> <p>class Demo(unittest.TestCase):</p> <pre><code>def setUp(self): self.verificationErrors = [] self.selenium = selenium("localhost", 4444, "*chrome", "https://workflowy.com/") self.selenium.start() def test_hh(self): sel = self.selenium sel.open("/accounts/register/") try: self.assertEqual("Sign Up FAIL", "Sign Up FAIL","Sign Up button issue1") except AssertionError, e: self.verificationErrors.append(str(e)) try: self.assertEqual("Sign Up FAIL", "Sign Up FAIL1","Sign Up button issue2") except AssertionError, e: self.verificationErrors.append(str(e)) def tearDown(self): self.selenium.stop() self.assertEqual([], self.verificationErrors) if __name__ == "__main__": #have to format the code this way as SO is complaining about 'bad indent' unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports')) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload