CAPABILITY GENERATOR

LambdaTest DocumentationVisual User Interface Testing ● Automated Screenshot API For Cross Browser Testing

Automated Screenshot API For Cross Browser Testing


Automated Screenshot API will help you capture full-page screenshots of any URL by invoking an API call to LambdaTest cloud servers. You can ensure cross browser compatibility of your website stays in check by performing bulk screenshot testing on a regular basis. You can do that without logging into LambdaTest, by executing a JSON file in your preferred API development environment such as Postman.

This document will help you leverage LambdaTest Automated Screenshot. You would learn how to:

  • Fetch all OS + Browser combinations.
  • Fetch all Screen Resolutions.
  • Fetch Screenshots of an already performed test session.
  • Start a Screenshot Test Session
    1. Test your locally hosted web pages.
    2. Test web pages with basic authentication.
    3. Test web pages with a Callback URL.
  • Stop a Screenshot test.

Prerequisites


  • LambdaTest Authentication Credentials
  • Be aware of your LambdaTest authentication credentials i.e. your LambdaTest username, access key and HubURL. You need to set them up as your environment variables. You can retrieve them from your LambdaTest automation dashboard by clicking on the key icon near the help button.

    • For Linux/Mac:
      $ export LT_USERNAME= {your lambdatest username}
      $ export LT_ACCESS_KEY= {your lambdatest access_key}
    • For Windows:
      $ set LT_USERNAME= {your lambdatest username}
      $ set LT_ACCESS_KEY= {your lambdatest access_key}

Fetch All OS + Browser Combinations


The below GET request will help you extract a list of all the combinations for (OS + Browser) offered by LambdaTest. You can download these combinations as a JSON file.

Requested URL:

Client URL would be as followed:

As you execute, you will find the Server response presented below.

Fetch Every Screen Resolutions


To get a list of all the available screen resolutions provided by LambdaTest for you to perform cross browser testing, you would need to execute the below GET request. The GET request will help you extract the respective response from our cloud servers in a JSON format.

Requested URL:

Client URL would be as followed:

As you execute, you will find the Server response presented below.

Fetch Details Of An Executed Test Session


In case you wish to fetch all the details from an already executed screenshot test session. These details will help you analyze the results of your screenshot test session at LambdaTest. You would get the below details:

  • Test Details:
    1. Test ID
    2. Test status
    3. Defer time
    4. Tested URL
    5. Callback URL(if any)
  • Screenshot Details:
    1. Operating System
    2. Browser
    3. Browser Version
    4. Status
    5. Screenshot URL
    6. Thumbnail URL
    7. Activity ID
    8. Resolution

Requested URL:

Note: Test ID is a mandatory field for making use of this GET request. This would fetch details in JSON format for all bulk screenshots captured in a test session specified by you.

Client URL would be:

Example Value:

Run A Screenshot Test


To start a screenshot test using the API, you would need to trigger the below POST request.

Client URL would be as followed:

Example value:

Screenshot Testing For Locally Hosted Web Applications


To perform a screenshot test on your locally hosted web applications, you would need to declare the below parameter in your request before specifying the configurations:

"tunnel": true

Example Value:

Screenshot Test With Basic Authentication


Similarly, to perform a screenshot test on a web application with basic authentication, you would need to declare the below parameter in your request before specifying the configurations.

Example:

Route Test Details To Your Colleagues Through A Callback URL


By specifying a Callback URL, you can route your test details to a specific IP, or a specific URL. This would help you to share your test results with your colleagues or to keep them on a specific URL, so you could come back and assess these results when you have time. To invoke a Callback URL, you would need to declare the below parameter in your request before specifying the configurations.

Example Value:

Stop A Screenshot Test


In case you wish to stop a screenshot test, you can do so with the help of a PUT request. Test ID is again mandatory over here as you need to convey which particular screenshot test would you want to be aborted.

Requested URL:

Note: This will terminate only a running test session. Providing a TestID of an already completed test session will provide you with a 404 error as the server response.