Skip to main content
Creating Automated Runs with API

This article walks you through the process of creating an automated run using Testlio REST API.

Doris Sooläte avatar
Written by Doris Sooläte
Updated over a year ago

Requirements

You will need a few variables that you can get through Testlio Platform token management.

On Testlio App:

  1. Click “User > Token management”

  2. Click on the “Generate new token” button

  3. Type a token name, choose the workspace

  4. Check the “Run Public API” radio button

  5. Click “Generate token”

If you don’t have access to Testlio App or to the Token management, ask your contact person for the details.

The relevant variables you’ll need from this page are:

  • JWT authentication token: Testlio REST API uses JWT authentication.
    You need to attach an Autorization header to all of your request:

    Authorization: Bearer <your_JWT_token>
  • Identifiers for your workspace, project, etc.

    • project id

    • test run collection guid

    • automated run collection guid

Besides that, you’ll need a test package and an application build if you want to test a mobile app.

Resources

You can use this Postman collection (attached to the end of this document - create automated run.v20220118.postman_collection.json)

Instructions

Once we have all variables and artifacts we need we will proceed with the following request of HTTP request.

IMPORTANT: Order is important because we need data from the response in order to perform the subsequent HTTP calls.

1. Create automated run

POST /test-run/v1/collections/{{test-run-collection-guid}}/runs

Request body

{
"startAt": "{{$isoTimestamp}}",
"projectId": "{{projectId}}",
"type": "Automated"
}

Store the href from the response.

2. Save automated run configurations

2.1. Get the automated runs configuration

POST /automated-test-run/v1/collections/{{automated-run-collection-guid}}/search/run-configurations

Request body

{
"runHrefs": ["{{automated-run-href-from-step-1}}"]
}

Store the data[0].href from the response.

2.2. Update automated runs configuration

PUT {{automated-run-configuration-href-from-step-2}}

Body parameters

  • deviceAppType can be one of:

    • ANDROID or IOS for Mobile App

    • WEB for Mobile Web

    • OTHER for Desktop Web

  • type can be of:

    • BROWSER for Desktop Web

    • DEVICE (Default value) for android/IOS/Web

  • For Mobile testing, deviceTestType can be one of:

    • APPIUM_JAVA_JUNIT

    • APPIUM_JAVA_TESTNG

    • APPIUM_PYTHON

    • APPIUM_NODE

    • APPIUM_RUBY

  • For Desktop Web testing, deviceTestType can be one of:

    • SELENIUM_JAVA_TESTNG

    • SELENIUM_JAVA_JUNIT

    • SELENIUM_NODE

Request body example for Android/iOS

{
"deviceAppType": "ANDROID",
"deviceTestType": "APPIUM_JAVA_TESTNG",
"configuration": {
"location": {
"longitude": -5.78124,
"latitude": 37.18133
},
"radios": {
"bluetooth": true,
"gps": true,
"nfc": true,
"wifi": true
}
},
"executionConfiguration": {
"jobTimeoutMinutes": 15,
"videoCapture": true
}
}

Request body example for Desktop Web

{
"type": "BROWSER"
"deviceAppType": "OTHER",
"deviceTestType": "SELENIUM_NODE",
"executionConfiguration": {
"jobTimeoutMinutes": 15,
"videoCapture": true
}
}


3. Create an automated run plan

POST {{automated-run-href-from-step-1}}/plans

Request body

Store the href from the response.


4. Upload build

4.1. Get upload URL

POST /upload/v1/files

Request body

{
"prefix": "build-v3"
}

Store the put.href and get.href from the response.

4.2. Upload the application build

Attention: The upload URL from previous step is pre-signed. This means that you are not allowed to send Authentication header for this request.

PUT {{build-upload-put-href-from-step-4-1}}

Request body

Application build

Note: Content-Type header should be set to application/octet-stream

4.3. Get build collection

GET /project/v1/projects/{{projectId}}/collection

Request body

(no parameters needed, no request body)

Store the buildCollectionHref from the response.

4.4. Create the build

POST {{buildCollectionHref-from-step-4-3}}/builds/file?resign=true

Request body

{
"name": "filename.apk",
"url": "{{build-upload-get-href-from-step-4-1}}",
"version": "some.version.number"
}

Store the href from the response.

4.5. Attach build to plan

POST {{automated-run-plan-from-step-3}}/builds

Request body

{
"buildHref": "{{build-href-from-step-4-4}}",
"useOriginal": true
}

Store the href from the response.

5. Upload test package/specs

5.1. Get upload URL

POST /upload/v1/files

Request body

{
"prefix": "automated-run-attachment"
}

Store the put.href and get.href from the response.

5.2. Upload the test package/specs

The upload URL from the previous step is pre-signed. This means that you don’t need

Authentication header for this request.

POST {{test-pkg-upload-put-href-from-step-5-1}}

Request body

The test package zip file

Note: Content-Type header should be set to application/octet-stream

5.3. Create an automated run attachment for the test package

POST /automated-test-run/v1/collections/{{automated_run_collection_guid}}/attachments

Request body

{
"name": "test-package-filename.zip",
"fileType": "application/zip",
"attachmentType": "TestPackage",
"url": "{{test-pkg-upload-get-href-from-step-5-1}}",
"size": 123456789
}

Store the href from the response.

5.4. Attach test package attachment to plan

POST {{automated-run-plan-from-step-3}}/attachments

Request body

{
"attachmentHref": "{{test-pkg-attachement-href-from-step-5-3}}",
}

6. Devices

6.1. Create a device pool

POST /test-run/v1/collections/{{test-run-collection-guid}}/device-pools

Request body

{
"description": null,
"name": "Automated device",
"hidden": true,
"withoutDeviceAssignment": true,
"isGroup": false,
"isMultipleDevices": false
}

Store the href and the guidfrom the response.

6.2. Get available devices/browsers

For devices:

GET /automated-test-run/v1/devices/

Parameters

platform

ANDROID | IOS

For browsers

GET /automated-test-run/v1/browsers/

You can find a list of the available devices in data. Store the id for the device you want to use

6.3. Create device pool filter

POST /{{device-pool-href-from-step-6-1}}/filters

Either select automatedDevices or automatedBrowsers based on your requirement from step 6.2

Request body

{
"automatedDevices": [
{ "automatedDeviceGuid": "{{device-id-from-step-6-2}}" },
{ /* ... repeat for as many device as you need ... */ }
],
"isGroup": false
}

{
"automatedBrowsers": [
{ "automatedBrowserGuid": "{{browser-id-from-step-6-2}}" },
{ /* ... repeat for as many browser as you need ... */ }
],
"isGroup": false
}

6.4. Link device pool to plan

POST /{{automated-run-plan-href-from-step-3}}/plan-device-pools

Request body

{
"jobsCount": 1,
"devicePoolGuid": "{{device-pool-guid-from-step-6-1}}"
}



7. Schedule a run

PUT /{{automated-run-href-from-step-3}}

Request body

{
"status": "inProgress",
"projectId": {{projectId}}
}

8. Retrieve run results

GET /automated-test-run/v1/collections/{{automated-run-collection-guid}}/results

Parameters

testRunHref

{{automated-run-href-from-step-1}}

9. Related articles

Did this answer your question?