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

@Raiman:

I am facing issue while taking screenshots for failed cases. 
I have went through : https://answers.launchpad.net/sikuli/+question/259679

Code-
from sikuli import *
import unittest
import sys
_path = r"D:\Sikulix\HTMLTestRunner"
sys.path.append(_path)
import HTMLTestRunner

class TestDemo(unittest.TestCase):
    def testA(self):
        click("1520869861593.png")
        
        
    def testB(self):
        click("1520958741130.png")  //This is wrong image

class TestDemo2(unittest.TestCase):
    def testC(self):
        click("1520869861593.png")
    def testD(self):
        click("1520869861593.png")

def suite():
    suite = unittest.TestSuite()
    # TestDemo
    suite.addTest(TestDemo('testA'))
    suite.addTest(TestDemo('testB'))
    # TestDemo2
    suite.addTest(TestDemo2('testC'))
    suite.addTest(TestDemo2('testD'))

    return suite

suite = unittest.TestLoader().loadTestsFromTestCase(TestDemo)
outfile = open("D:\\Sikulix\\HTMLTestRunner\\report.html", "w") # path to 
report folder
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title=' Test project', 
description='Test Report' )
runner.run(suite)


I have taken htmltestrunner.py from Sikulix 1.1.1 
(\\sikulix\Lib\htmltestrunner.py)
 where below part is there for taking screenshot of failed cases-
 
     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')
    
    # added by RaiMan
    def generateTestScreenshot(self, test):
        imgdir = ''
        imgpath = ''
        if imgdir:
            x = str(test).split()
            tf = x[0]
            tc = x[1].split('.')[1][:-1]
            imgpath = os.path.join(imgdir, "%s-%s.png"%(tc, tf))
            shutil.move(capture(SCREEN), imgpath)
        return imgpath

But when I am executing test suite, it was not taking screenshots of failed 
cases. Please help me in this case.                 
                



-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to