Endtest

Endtest

›Advanced

Web Tests

  • How to create Web Tests
  • Finding elements in Web Applications
  • How to execute Web Tests
  • Assertions for Web Tests
  • IF Statements for Web Tests
  • Web Applications with restricted access
  • How to test in iframes
  • How to test in multiple tabs
  • How to test File Uploads
  • How to test File Downloads
  • How to test Emails
  • How to test PDF files
  • How to test Chrome Extensions
  • Dealing with reCAPTCHA
  • Dealing with Dynamic Locators
  • Dealing with Canvas Elements
  • Performing a Drag and Drop
  • Execute JavaScript
  • Testing WebRTC Applications
  • How to scroll in Web Tests
  • How to test Checkboxes
  • How to test Dropdowns
  • Dealing with Sessions
  • Web Crawler
  • Export Web Tests
  • Migrating from Selenium

Mobile Tests

  • How to create Mobile Tests
  • Finding elements in Mobile Applications
  • How to execute Mobile Tests
  • Assertions for Mobile Tests
  • IF Statements for Mobile Tests
  • How to scroll in Mobile Tests
  • Performing Complex Gestures

Advanced

  • Variables
  • Waits
  • Endtest API
  • Scheduler
  • Drive
  • Adding Collaborators
  • Computer Vision
  • Importing Test Cases
  • Using Loops
  • Data-driven Testing
  • Send API Requests
  • Read SMS
  • Execute SQL queries
  • Self-Healing Tests
  • Email Notifications
  • Slack Notifications
  • PagerDuty Notifications
  • Webhook Notifications
  • Automatic Backup
  • Advanced Settings
  • Multiple environments
  • How to stop a test
  • Utilities
  • Utilities API
  • Team
  • On-Premises

Integrations

  • Atlassian Jira
  • Slack
  • PagerDuty
  • Microsoft Teams
  • Mattermost
  • Jenkins
  • GitHub
  • Azure DevOps
  • GitLab
  • TeamCity
  • CircleCI
  • TravisCI
  • Bitbucket
  • Heroku
  • Bamboo Server
  • Test Case Management
  • BrowserStack
  • Sauce Labs

Endtest API

Introduction

You can easily integrate Endtest into your workflow by using our API.

These are the tasks you can perform with the Endtest API:

  1. Start a test execution.
  2. Start multiple test executions.
  3. Fetch the results for a test execution.
  4. Fetch the results for multiple test executions.
  5. Stop a test execution.
  6. Get the IDs and Names of all the test suites that you have access to.
  7. Get the IDs, Names and External IDs of all the test cases from a test suite.
  8. Upload a file in the Drive.
  9. Get the list of files uploaded in the Drive.
  10. Delete a file from the Drive.

1. Start a test execution

To get the API request for executing a test, just click on Get API Request from the Run Test Suite modal.

The API request contains the appId and appCode which are used to identify your user and do not change.


This API request can only be called with an HTTP Method of type GET.

Endtest API Parameters for starting a Web Test execution

Endtest API ParameterDescription
actionThe type of action (runWeb)
appIdThe App ID of the user
appCodeThe App Code of the user
suiteThe ID of the test suite
platformThe platform to run the test on
osThe operating system for the execution
browserThe browser for the execution
browserVersionThe browser version for the execution (latest or beta)
resolutionThe screen resolution for the execution
geolocationThe Geolocation for the execution
casesThe test cases to be executed
notesNotes that will appear in the execution

Endtest API Parameters for starting a Mobile Test execution

ParameterDescription
actionThe type of action (runMobile)
appIdThe App ID of the user
appCodeThe App Code of the user
suiteThe ID of the test suite
platformThe platform to run the test on
deviceThe mobile device to run the test on
appThe download link for the APK or IPA file
gridThe mobile device grid provider
casesThe test cases to be executed
notesNotes that will appear in the execution

The response from this API request contains a hash which can be used to uniquely identify that test execution.

You can also add variables directly in the API call.

For example, adding &username=Matt will automatically create the variable $username with the value Matt.

The Webhook URL and Webhook Notifications can be overwritten by adding &webhookUrl=your_webhook_url and &webhookNotifications=option, where option can be 0, 1 or 2.

0 = Do not send
1 = Send every time a test runs
2 = Send only when a test fails

If your Webhook URL is https://my-own-webhook.com and you want to receive notifications every time a test is executed, you would need to add the following to your Endtest API call:
&webhookUrl=https://my-own-webhook.com&webhookNotifications=1

The Endtest API request for starting test executions has been updated on October 12 2021.

The legacy Endtest API requests are still supported.

You can download the legacy Endtest API Mappings for starting a web test execution from here:

Endtest_API_Mappings_for_Web_Tests.pdf

2. Start multiple test executions

The only way to start multiple test executions with one single Endtest API request is by using Labels.

In the Endtest API request, replace the suite parameter with the label parameter and provide the name of the label instead of the test suite ID.

This API request can only be called with an HTTP Method of type GET.

Endtest API Parameters for starting multiple Web Test executions

Endtest API ParameterDescription
actionThe type of action (runWeb)
appIdThe App ID of the user
appCodeThe App Code of the user
labelThe label assigned to the test suites
platformThe platform to run the test on
osThe operating system for the execution
browserThe browser for the execution
browserVersionThe browser version for the execution (latest or beta)
resolutionThe screen resolution for the execution
geolocationThe Geolocation for the execution
casesThe test cases to be executed
notesNotes that will appear in the execution

Endtest API Parameters for starting multiple Mobile Test executions

ParameterDescription
actionThe type of action (runMobile)
appIdThe App ID of the user
appCodeThe App Code of the user
labelThe label assigned to the test suites
platformThe platform to run the test on
deviceThe mobile device to run the test on
appThe download link for the APK or IPA file
gridThe mobile device grid provider
casesThe test cases to be executed
notesNotes that will appear in the execution

The request will respond with the unique hashes for each test execution, separated by commas.

The value from the label parameter is case-sensitive.

Only one Label Name can be provided in the label parameter for each request.

Only one configuration can be provided in each request.

3. Fetch the results for a test execution

To get the results from a test execution with our API, use a GET request with the following format:

https://app.endtest.io/api.php?action=getResults&appId=[your app id]&appCode=[your app code]&hash=[the returned hash]&format=[html or json or json-light]

Replace [your app id] and [your app code] with your appId and appCode values, which you can retrieve from the Settings page by clicking on the Show API Credentials button.

Replace [the returned hash] with the hash that was returned by the Endtest API request for starting a test execution.

You have the option to choose a format, either html or json or json-light.

This API request can only be called with an HTTP Method of type GET.

Endtest API ParameterDescription
actionThe type of action (getResults)
appIdThe App ID of the user
appCodeThe App Code of the user
hashThe unique hash for that test execution
formatThe format of the results (json, json-light or html)

If you're planning to integrate Endtest into your continuous delivery workflow, you're going to need to use both the API request for starting a test execution and the API request for fetching the results.

Because it takes time for a functional test to finish, you either need to add a sleep in your script or a loop that calls the API request for fetching the results at a certain interval until the test execution is finished.

Here is a sample Shell script that shows you how to do that:

#!/bin/bash
hash=$(curl -X GET --header "Accept: */*" "${3}")
for run in {1.."${4}"}
do
  sleep 30
  result=$(curl -X GET --header "Accept: */*" "https://app.endtest.io/api.php?action=getResults&appId=${1}&appCode=${2}&hash=${hash}&format=json")
  if [ "$result" == "Test is still running." ]
  then
    status=$result
    # Don't print anything
  elif [ "$result" == "Processing video recording." ]
  then
    status=$result
    # Don't print anything
  elif [ "$result" == "Stopping." ]
  then
    status=$result
  elif [ "$result" == "Erred." ]
  then
    status=$result
    echo $status
  elif [ "$result" == "" ]
  then
    status=$result
    # Don't print anything
  else
     echo "$result" | jq
     exit 0
  fi
done
exit

This sample script would require the following arguments:

  1. The App ID for your account.
  2. The App Code for your account.
  3. The API Request for starting the test execution.
  4. The number of times the API request for fetching the results will be sent once every 30 seconds.

For example, if you know that your test execution usually takes 3 minutes, you should use the value 7.

7 x 30 seconds = 210 seconds > 3 minutes

Don't forget to make your Shell script executable by running the following command:

sudo chmod +x test.sh

And you would also need to install the jq package:

sudo apt-get install jq

The command for running the sample Shell script would have the following format:

./test.sh app-id app-code api-request-to-start-test-execution number-of-loops

Let's pretend we have the following values:

App ID = 44233559

App Code = 22381137

Endtest API Request to start test execution = "https://app.endtest.io/api.php?action=runTestSuite&appId=44233559&appCode=22381137&testSuite=106877&selectedPlatform=windows&selectedOs=a&selectedBrowser=chrome&selectedResolution=d&selectedLocation=sanfrancisco&selectedCases=all&writtenAdditionalNotes="

Number of loops = 10

The command for running the sample Shell script would look like this:

./test.sh 44233559 22381137 "https://app.endtest.io/api.php?action=runTestSuite&appId=44233559&appCode=22381137&testSuite=106877&selectedPlatform=windows&selectedOs=a&selectedBrowser=chrome&selectedResolution=d&selectedLocation=sanfrancisco&selectedCases=all&writtenAdditionalNotes=" 10

The sample script will output the Results in JSON format with the following keys:

  • test_suite_name {string} - The name of the test suite.
  • configuration {string} - The configuration of the machine or mobile device on which the test was executed.
  • test_cases {int32} - The number of test cases.
  • passed {int32} - The number of assertions that have passed.
  • failed {int32} - The number of assertions that have failed.
  • errors {int32} - The number of errors that have been encountered.
  • start_time {timestamp} - The timestamp for the start of the test execution.
  • end_time {timestamp} - The timestamp for the end of the test execution.
  • detailed_logs {string} - The detailed logs for the test execution.
  • screenshots_and_video {string} - The URL for the screenshots and the video recording of the test execution.
  • test_case_management {string} - The ID, Name, Status and External IDs for each Test Case.

Using the json-light format instead of json means that the Results in JSON format won't include the detailed_logs and screenshots_and_video items.

You can also use the value of the hash variable to generate the link to the Results page for that test execution:

results=https://app.endtest.io/results?hash="$hash"

An alternative way to retrieve the results from a test execution is to add your Webhook URL in the Webhook Notifications settings or in the Endtest API request for starting a test execution.

After the test execution is finished, the results will be automatically sent to that Webhook URL.

4. Fetch the results for multiple test executions

The exact same Endtest API request can be used, the only difference is that you can provide multiple unique hashes, separated by commas.

This API request can only be called with an HTTP Method of type GET.

Endtest API ParameterDescription
actionThe type of action (getResults)
appIdThe App ID of the user
appCodeThe App Code of the user
hashList of unique hashes, separated by commas
formatThe format of the results (json or html)

5. Stop a test execution

To stop a test execution with the Endtest API, use the following command:

https://app.endtest.io/api.php?action=stopTest&appId=[your app id]&appCode=[your app code]&hash=[the returned hash]

Replace [your app id] and [your app code] with your appId and appCode values, which you can retrieve from the Settings page by clicking on the Show API Credentials button.

Replace [the returned hash] with the hash that was returned by the Endtest API request for starting a test execution.

This API request can only be called with an HTTP Method of type GET.

You can also stop a test execution directly from the UI, by clicking on the Stop Test button from the Results page.

You can also use the Stop Test option from the Miscellaneous action in your test. The test will automatically stop when it reaches that step.

More details are available in the How to stop a test chapter.

6. Get the IDs and Names of all the test suites that you have access to

To get the ids and names of all the test suites, use the following command:

https://app.endtest.io/api.php?action=getTestSuites&appId=[your app id]&appCode=[your app code]

Replace [your app id] and [your app code] with your appId and appCode values.

This API request can only be called with an HTTP Method of type GET.

7. Get the IDs, Names and External IDs of all the test cases from a test suite

To get the ids, names and external IDs of all the test cases from a test suite, use the following command:

https://app.endtest.io/api.php?action=getTestCases&appId=[your app id]&appCode=[your app code]&testSuite=[id of the test suite]

Replace [your app id] and [your app code] with your appId and appCode values.

Replace [id of the test suite] with the ID of your test suite.

You can get those values by clicking on Get API Request from the Run Test Suite modal.

This API request can only be called with an HTTP Method of type GET.

8. Upload a file in the Drive

To upload a file in the Drive, use the following cURL command:

curl -X POST "https://app.endtest.io/api.php" -F "file=@/path/to/file" -F "appId=[your app id]" -F "appCode=[your app id]" -F "visibility=[your visibility preference]"

Replace /path/to/file with the local path of your file.

Replace [your app id] and [your app code] with your appId and appCode values, which you can retrieve from the Settings page by clicking on the Show API Credentials button.

Replace [your visibility preference] with OnlyMe or MyEntireTeam.

This API request can only be called with an HTTP Method of type POST.

The response from this API request contains the File Download URL for the uploaded file.

Sample cURL command:

curl -X POST "https://app.endtest.io/api.php" -F "file=@/Users/matt/Desktop/calculator.ipa" -F "appId=20112504" -F "appCode=42554172" -F "visibility=OnlyMe"

Sample cURL response:

https://endtest-files.s3.us-west-2.amazonaws.com/dEREnfuqPYQRaYFWdyY7zwa0BL97lu/calculator.ipa


9. Get the list of files uploaded in the Drive

To get the list of files from the Drive, use the following command:

https://app.endtest.io/api.php?action=getFilesFromDrive&appId=[your app id]&appCode=[your app code]

Replace [your app id] and [your app code] with your appId and appCode values.

This API request can only be called with an HTTP Method of type GET.

It will return a JSON which contains the names, the URLs and the access rules for each file.

10. Delete a file from the Drive

To delete a file from the Drive, use the following command:

https://app.endtest.io/api.php?action=deleteFile&appId=[your app id]&appCode=[your app code]&url=[file URL]

Replace [your app id] and [your app code] with your appId and appCode values.

Replace [file url] with the URL of the file from the Endtest Drive.

This API request can only be called with an HTTP Method of type GET.

Only the user who uploaded the file can delete it with the Endtest API.

← WaitsScheduler →
  • Introduction
  • 1. Start a test execution
    • Endtest API Parameters for starting a Web Test execution
    • Endtest API Parameters for starting a Mobile Test execution
  • 2. Start multiple test executions
    • Endtest API Parameters for starting multiple Web Test executions
    • Endtest API Parameters for starting multiple Mobile Test executions
  • 3. Fetch the results for a test execution
  • 4. Fetch the results for multiple test executions
  • 5. Stop a test execution
  • 6. Get the IDs and Names of all the test suites that you have access to
  • 7. Get the IDs, Names and External IDs of all the test cases from a test suite
  • 8. Upload a file in the Drive
  • 9. Get the list of files uploaded in the Drive
  • 10. Delete a file from the Drive
Copyright © 2023 Endtest