← Back to team overview

sikuli-driver team mailing list archive

[Question #250286]: HTML TestRunner report NOT showing screenshots

 

New question #250286 on Sikuli:
https://answers.launchpad.net/sikuli/+question/250286

I'm trying to get sikuli to capture the screenshot of the application everytime an assert is executed. 

This is what my script looks like:

from sikuli import *
import unittest
import HTMLTestRunner

class BOSTests(unittest.TestCase):
              
    def test_Receipting(self):
        # navigate to Invoice / Return Invoice screen
        doubleClick("Inventory.png")
        doubleClick("OrderincRece.png")
        doubleClick("InvoiceRetur.png")
        sleep(2)
        if exists("InvoiceRetur-1.png", 10):
            assert True, "Invoice / Return Invoice screen found"
        else:
            assert False, "Invoice / Return Invoice was NOT loaded"           
        
        # enter details
        click("Insert.png")
        type("Lookup.png", "GHPL CONFEC")
        sleep(1)
        click("1402361820798.png")

        # generate Invoice number using date/time stamp - ddmmhhmmss
        invoice = time.strftime("%d%m")
        invoice = invoice + time.strftime("%H%M%S")
        type(invoice)
        print ("Invoice Number: " + invoice)
        
        # Approve - Yes to Approve and Yes to Print
        click("Approge.png")
        if exists("onfirmPostSu.png", 10):
            assert True, "Post Supplier Invoice - Confirmation Dialog appeared" 
            click("Yes.png")
        else:
            assert False, "Post Supplier Invoice - Confirmation Dialog did NOT appear"      
        
suite = unittest.TestLoader().loadTestsFromTestCase(BOSTests)
outfile = open("C:\\Temp\\SikuliReports\\report.html", "w") # path to report folder
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title=' Auto Report', description='BOS Receipting...' )
runner.run(suite)


I have also updated the HTMLTestRunner.py based on RaiMan's comments from another post and this is what my HTMLTestRunner.py looks like

def addSuccess(self, test):
        self.success_count += 1
        TestResult.addSuccess(self, test)
        output = self.complete_output()
        #self.result.append((0, test, 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('.')

    def addError(self, test, err):
        self.error_count += 1
        TestResult.addError(self, test, err)
        output = self.complete_output()
        #self.result.append((2, test, output, _exc_str, ''))
        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')


I'm using Sikuli X-1.0rc3(r905) IDE for development. I can see <<print ("Invoice Number: " + invoice)>> being reported in the HTML report but not any screenshot. Also, when an assert fails, it generates a blank report with nothing in it.

Any help is appreciated.

Thanks,
Raza

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.