← Back to team overview

sikuli-driver team mailing list archive

[Question #674430]: Adding screenshot in test output for find failed error

 

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

I am using HTMLTestRunner to generate html output reports for my tests. I want screenshot in my output report for find failed errors.
My FindElement function looks like below:

def findElement( element ):       
        print "Finding element: " + str(element)
        try:
                
                find(element)
        except FindFailed:
                stack = traceback.extract_stack(limit = 2)
                print "Unable to find element: " + Constants.BaselineFolder + str(element) + "\nBelow are exception details:\n" + str(sys.exc_info()[0]) + " -- line no. " + str(stack[0][1])
                raise

But if any element is not found during execution, then screenshot is not getting displayed in output report.
Although, screenshot appears properly in case of assert failures for below assert function:

def assertElementExists( element ):
        print "Asserting whether element exists: " + str(element)
        try:
                
                assert(exists(element))
        except AssertionError:
                stack = traceback.extract_stack(limit = 2)
                print "Unable to assert image exists: " + Constants.BaselineFolder + str(element) + "\nBelow are exception details:\n" + str(sys.exc_info()[0]) + " -- line no. " + str(stack[0][1])
                raise

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