Delayed screenshot in a Pass testcase with HTMLTestRunner

Asked by Luiz Felipe

I´m using HTML Test Runner to generate reports for my executions.
I have modified the original file HTMLTestRunner.py to include screenshots for all status (Error, Failures and Pass) and it does work, however for Passed executions the screenshot is taken only after the TearDown is executed, (which makes the screenshot being taken of the browser a moment before the logout for my code). When the test fail,s the screenshot is taken correctly.

I have tried to include some sleeps to check if the issue was with the execution speed, but it didnt help, even with a sleep (30) the issue stayed the same. I have also tried to delete the TearDown and include the logout logic in my test, after the assert, but the screenshot taken was after the logout process.

This is a piece of my code:

class PerfilAcesso(unittest.TestCase):
    def setUp(self):
        App.open("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")

    def test_visualiza_perfil_admin(self):
        click("1496165464521.png")
        paste("login")
        type(Key.TAB)
        #click("1496165521309.png")
        paste("password")
        click("1496165601742.png")
        sleep(5)
        click("1496165658452.png")
        sleep(2)
        assert exists("1498077813353.png")

    def tearDown(self):
        sleep(2)
        click("1498079107968.png")
        sleep(1)
        type(Key.F4, KeyModifier.ALT)

suite = unittest.TestLoader().loadTestsFromTestCase(PerfilAcesso)
outfile = open("C:\\EvidenciaTeste2\\OR-3130-teste.html", "w") # path to report folder
screenshotfile = "C:\\EvidenciaTeste2"
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title='OR-3130', description='...',dirTestScreenshots=screenshotfile)
runner.run(suite)

This is how the HTMLTestRunner.py looks:
    def addSuccess(self, test):
        self.success_count += 1
        TestResult.addSuccess(self, test)
        output = self.complete_output()
        self.result.append((0, test, output, '', self.generateTestScreenshot(test)))
        if self.verbosity > 1:
            sys.stderr.write('ok ')
            sys.stderr.write(str(test))
            sys.stderr.write('\n')
        else:
            sys.stderr.write('P')

    def addError(self, test, err):
        self.error_count += 1
        TestResult.addError(self, test, err)
        _, _exc_str = self.errors[-1]
        output = self.complete_output()
        self.result.append((2, test, output, _exc_str, self.generateTestScreenshot(test)))
        if self.verbosity > 1:
            sys.stderr.write('E ')
            sys.stderr.write(str(test))
            sys.stderr.write('\n')
        else:
            sys.stderr.write('E')

    def addFailure(self, test, err):
        self.failure_count += 1
        TestResult.addFailure(self, test, err)
        _, _exc_str = self.failures[-1]
        output = self.complete_output()
        self.result.append((1, test, output, _exc_str, self.generateTestScreenshot(test))) # modified by RaiMan
        if self.verbosity > 1:
            sys.stderr.write('F ')
            sys.stderr.write(str(test))
            sys.stderr.write('\n')
        else:
            sys.stderr.write('F')

Can someone help me to understand this behaviour?

Thanks,

Question information

Language:
English Edit question
Status:
Expired
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.