LambdaTest Launches API For Selenium Automation!

Posted by Harshit Paul | April 3, 2019
Automation β€’ LambdaTest Updates β€’

30214 Views | 8 Min Read

LambdaTest Launches API For Selenium Automation!

At the start of the year, we launched our LambdaTest online Selenium automation grid that can help you perform cross browser compatibility testing on a scalable on-cloud selenium infrastructure. We have seen a tremendous response for the platform and we are humbled by the positive feedbacks.

However to be honest there were few shortcomings as well, especially for enterprise people. Most important of which was related to integrating LambdaTest in test reporting workflows as well. To summarize, till now detailed results of tests run on LambdaTest platform can only be obtained by coming to the LambdaTest automation platform. Till now is the key word here! πŸ™‚

We are now live with APIs for our LambdaTest Selenium automation testing platform, that you can leverage to extract and manage test and build information such as build test status, individual test status, test run time, errors, test logs, command by command screenshots, and even available browser environments on LambdaTest platform.

This will help automation experts in truly automating the whole testing workflow and integrate test results automatically in their test cycles. Now in addition to integrating LambdaTest Selenium Grid in their test platform, developers can also extract data of test results and use it in preparing automated build health reports. Build using RESTful API architecture style, LambdaTest APIs can be used with any continuous integration and continuous deployment platform to fully automate your test workflow.

Wondering What You Can Do With LambdaTest Automation API?

When you are performing automation testing with Selenium on a cloud-based platform such as LambdaTest then every tester would have two primary concern before proceeding with test automation. How do I keep a record of analytics, test results? How do I share them with my colleagues?

LambdaTest API helps you to get rid of these concerns by allowing you to manage and organize your test builds, test sessions, tunnel status, and by providing you with a json format file of platforms which contains syntax for every browser and browser version according to a particular OS.

You can fetch and manage all test data belonging to an account including fetching specific build details, delete a build or test session, fetch specific information from a test session, fetch command-by-command screenshots of test sessions, fetch command logs, network logs, Selenium logs, and more.

We will point out the role of every endpoint that you may invoke for automated cross browser testing on Selenium Grid of LambdaTest. Before we do that, make a note of our computed API URL from below:

https://api.lambdatest.com/automation/api/v1/

You would have to append your end-points on this computed URL to leverage LambdaTest API.

Everything You Can Do With Your Test Builds?

β†’ Fetch every build of an account by triggering a GET request on the below endpoint.

/builds

You can limit the number of records. You can also view builds with various filters based on status, build date range, sort by users, start date and end date in ascending and descending order. You can even sort on multiple columns at once.

β†’ Fetch details of a specified test session. These details include information such as name, status, OS, browser, browser versions and all generated logs endpoint.

/builds/{build_id}

β†’ If there is a build you wish to delete. You can do that using a DELETE request on the below endpoint.

/builds/{build_id}

β†’ If you wish to change the name of a particular build. You can do that using a PATCH request on the below endpoint.

/builds/{build_id}

Everything You Can Do With Your Test Sessions?

β†’ Fetch a list of all test sessions by triggering a GET request on the below endpoint.

/sessions

You can also limit the number of records, and paginate through your data using Parameters.

β†’ Fetch details which are specific to a particular test session by triggering a GET request on the below endpoint.

/sessions/{session_id}

These details could be the name, status, OS, browser, browser version & endpoints of all generated logs.

β†’ If you wish to delete a test session. You can do that using a DELETE request on the below endpoint.

/sessions/{session_id}

β†’ If you wish to update the name of a particular test session or its status. You can do that using a PATCH request on the below endpoint.

/sessions/{session_id}

β†’ To fetch all screenshots of a test session, use the below endpoint with a GET request.

sessions/{session_id}/screenshots

β†’ To fetch a video recording of a test session, use the below endpoint with a GET request.

sessions/{session_id}/video

β†’ To fetch Command logs of a test session, use the below endpoint with a GET request.

sessions/{session_id}/log/command

This would extract all the commands there were executed in your test session. All the Command logs will be extracted in a plain JSON text file.

β†’ To fetch Selenium logs of a test session, use the below endpoint with a GET request.

sessions/{session_id}/log/selenium

This would extract logs containing grid requests and responses of a test session. All the Selenium logs will be extracted in a plain JSON text file.

β†’ To fetch Network logs of a test session, use the below endpoint with a GET request.

sessions/{session_id}/log/network

These logs would highlight every URL that was requested during a test session. All the Network logs will be extracted in a plain JSON text file.

β†’ To fetch Console logs of a test session, use the below endpoint with a GET request.

sessions/{session_id}/log/console

To debug console errors thrown by an application under a test session. All the Console logs will be extracted in a plain JSON text file.


Download Whitepaper

How Do I Manage Multiple Tunnel Status To Perform Localhost Testing?

Using Lambda Tunnel you can perform testing on your locally hosted web-app or website through an SSH connection between your local machine and LambdaTest cloud servers. No matter how big your testing team is! If they are testing on various modules of your web-app through Lambda Tunnel then you can easily acknowledge the status of all running tunnels in your LambdaTest account. Simply, use the below endpoint with a GET request.

/tunnels

You can also stop any unnecessary tunnel by triggering a DELETE request on the below endpoint.

/tunnels/{tunnel_id}

Is There A Way For Me To Fetch Syntax For All The Platforms Offered By LambdaTest?

LambdaTest offers more than 2000+ browsers and browser versions. Using LambdaTest Capabilities Generator to retrieve coded values for hundreds of browsers + platforms could be a bit struggling. However, using the below endpoint at the end of the Computed URL will provide you with the syntax of every browser, browser version with respect to all Operating System.

/platforms

How Do I Download Screenshots Of A Test Session?

By default LambdaTest platform automatically capture a screenshot of every Selenium command step that gets executed in your Selenium test script. You can toggle this feature using desiredcapabilities class that you pass on in each test. But what if you wish to access these screenshots without logging into LambdaTest automation?

LambdaTest API will help you fetch screenshots of your Selenium automation script execution. All you need to do is append the below endpoint on the earlier mentioned Computed URL with a GET request.

/sessions/{session_id}/screenshots

How Do I Fetch Video Recording Of A Particular Test Session?

In addition to step by step screenshots, we also provide complete test execution video recording as well. Again this feature can be toggled through desiredcapablilties class. If you wish to fetch the video of the test session, then you can do that by using the below endpoint using a GET request.

https://api.lambdatest.com/automation/api/v1/sessions/{session_id}/video

How Do I Fetch Network, Command, Selenium, or Console Logs For A Particular Test Session?

Testing is said to be an erratic activity. Especially, if we refer to test automation. A script that ran seamlessly today, may not run at all the next day. It is why having logs of every test session are recommended as a best practice. So, in case your automation script goes south, you can analyze the logs to debug what went wrong.

Keeping that in mind, we have come up with the below endpoints that would help you fetch various types of logs for a test session.

Command
Description
sessions/{session_id}/log/command
Fetches Command log of a test session
sessions/{session_id}/log/selenium
Fetches Selenium log of a test session
sessions/{session_id}/log/network
Fetches Network log of a test session
sessions/{session_id}/log/console
Fetches Console log of a test session

Final Thoughts: Prepare Rock Solid Test Reports

Not only will our API empower you to come up with finer test reports. It will also help the developers with all the logs they may need for debugging any anomalies. So, automate your testing workflow entirely by gaining instant & detailed information around your test session, build logs, recording etc. of your executed Selenium automation tests with LambdaTest API. The best part, you can do all this without logging into our platform each time.

We hope you like LambdaTest API. In case you don’t then feel free to shout at us! We are also open for any suggestions. You can speak with our experts through our 24×7 chat support, or drop a mail to support@lambdatest.com.

Happy Testing! πŸ™‚

Written by Harshit Paul

Harshit works as a product growth specialist at LambdaTest. He is also an experienced IT professional, who loves to share his thoughts about the latest tech trends as an enthusiast tech blogger.

Related Articles