← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #177954]: Can sikuli take a screenshot on failure / error? --- rc3: currently no

 

Question #177954 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/177954

The Happy Rock posted a new comment:
Thanks for the quick answer.

I was able to find a reasonable workaround.

Using the information from this question :
https://answers.launchpad.net/sikuli/+question/164161

I added the following code to my tearDown methods that takes a
screenshot if there was an error :

from java.awt import *
from java.io import File
from javax.imageio import ImageIO

if hasattr(test, 'failureException'):
     robot = Robot()
     theImage = robot.createScreenCapture(Rectangle(Toolkit.getDefaultToolkit().getScreenSize()))
     ImageIO.write(theImage, "png", File(r"C:\myPic.png"))

Note: test is an instance of TestCase

The solution isn't perfect, since error in setUp won't get a screenshot
and you have to put code into every test rather than having it
automatically fire.

Still it is nice that I have java and python at my disposal to create a
workaround

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