Reputation: 21
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?
Upvotes: 2
Views: 741
Reputation: 11
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.
Upvotes: 1