Skip to main content

Espresso Screenshot Capture

Real Devices Only

The Espresso Screenshot Capture functionality allows you to take screenshots of errors to support the visual verification of your debugging process.

Capturing Screenshots

To take screenshots during an Espresso test run, follow the steps below. Make sure to handle exceptions in your test code to ensure a proper test run.

To capture screenshots:

  1. Add the utility class to your project. See our Java example below:
SauceLabsCustomScreenshot Class
loading...
  1. Add the following code to your Espresso test scripts.
SauceLabsCustomScreenshot.capture("my-screenshot");

See our Java example below:

Sample Espresso test script
loading...
  1. Run your test on Sauce Labs Real Devices.

  2. After the test has run successfully, on the Test Cases page, click the Download Screenshots tab to download a .zip file with all the screenshots for each test case as shown below:


    Mobile app settings navigation

You can also use the API to fetch captured screenshots. To fetch the screenshots use the following API request:

 curl --compressed \
-O https://{SAUCE_USERNAME}:{SAUCE_ACCESS_KEY}@{DATA_CENTER}.saucelabs.com/v1/rdc/jobs/{JOB_ID}/screenshots.zip

The endpoint will return a .zip file of all screenshots captured during the session.

Limitations

note
  • The screenshots cannot exceed more than 200 MB in size.
  • You cannot change the filename of the screenshot. The code we provide allows you to supply the capture method with a string, but currently the string is ignored. We use a counter for the screenshot name. This is a known bug.