froglogic / All / Squish tip of the week: Capture screenshot on error or failure

Squish tip of the week: Capture screenshot on error or failure

Need a visual at the time of error or failure?

While script errors or verification point failures return information about the issue, a picture, in addition to data, may further clarify the reason for the issue.

Enabling testSettings.logScreenshotOnError or testSettings.logScreenshotOnFail fail in a script or a portion of a script captures a screenshot of the entire desktop at the time the script error or verification point failure occurs.

The script below contains both testSettings.logScreenshotOnError and testSettings.logScreenshotOnFail set to true. The verification point checks for a string in a particular object which does not match. The Test Results illustrate not only the value comparison failure, but also provide an interactive link to the screenshot captured at the time of error.

Sample Script

Sample Script

Test Results

click to view larger image

Screenshot Captured

logScreenshot_image

For more information related to screenshot logging see:

How to Create Automatic Screenshots on Test Failures and Errors

11 Comments

Is it possible to configure to which folder the screenshots are saved to?

Screenshots which are logged by “testSettings.logScreenshotOnError”, will be stored within the folder where test resolts go.

With my tests, the screenshots are saved here:

Duco.Risselada$\Cached\My Documents\Squish Test Results\2017-02-15T17-11-36+0100\1

I can reproduce this on different boxes, where should I change destination to save “ErrorImages” under test workspace?
Error Script Error (Screenshot in “C:/Users/garg/Documents/Squish Test Results/2017-03-28T09-42-30-0400/1\swift\tst_swift_sys_ebix_001\errorImages\error_1.png”) Mar 28, 2017 9:44:24 AM
Object ‘:SWIFT_TreeItem0’ not found. Object name not found in Object Map.
C:\Users\garg\Documents\Squish Test Results\2017-03-28T09-42-30-0400\1\swift\tst_swift_sys_ebix_001\errorImages\error_1.png

    Any more information on this?

      Hello everyone.

      The error screenshot folder is not configurable.

      You can configure the folder where the Squish IDE creates/stores the test results when executing test cases via the Squish IDE at Edit > Preferences > Squish > Logging.

      With best regards

      Clemens Anhuth

Hello, is it possible to get the screenshots generated when running the squishrunner from the command line and in the same time to get the ‘html’ report? We run the squishrunner with these parameters: “squishrunner –testsuite blabla –resultdir results –reportgen html,results”, but it finishes with “Cannot specify both report generator and results directory for html report. Only report generator should be specified”. The thing is, that we need both – the html report and also the screenshots. How can this be achieved?

Hello Stephen.

The screenshots should be taken regardless of any of the squishrunner command line options. So it should work when you just leave away the –resultdir option.

With best regards

Clemens Anhuth

    Hi Clemens, thanks for your answer. I am sorry, but I do not understand – you say “should be taken regardless of any of the squishrunner command line options” and then “So it should work when you just leave away the –resultdir option” Are not these two sentences in contradition? As I said, I need to specify both ‘-resultdir’ parameter and also to save the screenshots (which is done by adjusting the test suite config.xml file).

      Hi Clemens, thanks for your answer. I am sorry, but I do not understand – you say “should be taken regardless of any of the squishrunner command line options” and then “So it should work when you just leave away the –resultdir option” Are not these two sentences in contradition?

      Hello Stephen.

      1) Taking and storing of error screenshots cannot be disabled by squishrunner parameters.

      2) Some squishrunner options are mutually exclusive.

      You are trying to use mutually exclusive parameters, but that is unrelated to taking error/fail screenshots, or not.

      As I said, I need to specify both ‘-resultdir’ parameter and also to save the screenshots (which is done by adjusting the test suite config.xml file).

      I am not aware of a relation between the config.xml file and error/fail screenshots.

      Perhaps a blog is not a good approach to discuss technical issues. I recommend that you contact squish@froglogic.com to elaborate in more detail.

      With best regards

      Clemens Anhuth

Leave a Reply

Your email address will not be published. Required fields are marked *

Copy link
Powered by Social Snap