I am using JUnit and Sikuli to run automated GUI tests. I want to take a screenshot whenever an error occurs with the test (usually this is a FindFailed exception). Specifically, I am hoping to integrate these screenshots with the HTML reports generated by JUnit. Does anyone have any experience with this?
Asked
Active
Viewed 705 times
2
-
I am not familiar with Sikuli, but you can take a screen shot with java: http://stackoverflow.com/questions/58305/is-there-a-way-to-take-a-screenshot-using-java-and-save-it-to-some-sort-of-image – cheffe Jul 03 '14 at 08:26
1 Answers
1
You can easily do that with sikuli by using the shutil module. The code will look something like this:
import shutil capture(region)
region = SCREEN in this case, or you can also specify a region. You can throw this code in your catch block to get the screenshot when there is an error.
In my project, I have a tracker class, that will generate log file and every time I put out a log with the word "ERROR" in it, I call this to get a screenshot, that way, I will have a screenshot of every error, and not just the findfailed exception.

Bee
- 11
- 1