Trigger Test Plans Remotely


You can use Testsigma API to trigger test executions remotely. This is useful when you want to fully automate continuous testing within your CI/CD pipeline, and have already integrated Testsigma with a CI tool you use, such as Jenkins, TravisCI, GitLab, Codeship, CircleCI, etc..


Prerequisites


Trigger Test Plans Using API

This endpoint allows users to trigger a Test Plan execution remotely.

Request Type POST
Endpoint https://app.testsigma.com/api/v1/execution_results
Authorization Bearer <api_token>
<api_token> is the same as the Testsigma API Key mentioned above.
Request Body Type JSON
Request Body {
"executionId":
"executionConfig" : {
"name": "config 2"
"id": "2"
}
"uploadVersions":
{
"<DeviceID>": "<UPLOADVERSION_ID> "
}
}
Response Body {
   "id": 337,
   "execution": null,
   "executionId": 274,
   "startTime": 1633612675726,
   "endTime": null,
   "duration": null,
   "result": "QUEUED",
   "status": "STATUS_CREATED",
   "message": "Test Plan execution is initiated and waiting to be queued",
   "executedBy": 43,
   "buildNo": null,
   "environmentId": null,
   "totalCount": 0,
   "failedCount": 0,
   "passedCount": 0,
   "abortedCount": 0,
   "stoppedCount": 0,
   "notExecutedCount": 0,
   "preRequisiteFailedCount": 0,
   "queuedCount": 0,
   "isVisuallyPassed": null,
   "environment": null,
   "childResult": null,
   "reRunParentId": null,
   "reRunType": null,
   "triggeredType": "API",
   "totalRunningCount": 0,
   "executionDetails": {
   "page_timeout": 30,
   "element_timeout": 30,
   "recovery_action": "Run_Next_Testcase",
   "on_aborted_action": "Reuse_Session",
   "screenshot_option": "FAILED_STEPS",
   "group_prerequisite_fail": "Abort",
   "test_case_prerequisite_fail": "Abort",
   "test_step_prerequisite_fail": "Run_Next_Testcase",
   "global_param_name": null
   },
   "totalQueuedCount": 0
}

Request/Response fields

  • executionId: ID of the Test Plan
  • result: Result Status of the Test Plan - QUEUED, PASSED, FAILED, ABORTED, or STOPPED
  • status: Current Status of the Test Plan creation - STATUS_CREATED
  • executedBy: ID of the executor
  • buildNo: Build Number specified in the Test Plan Trigger call
  • isVisuallyPassed: Whether visual testing passed or not. True or False.
  • environment: Environment parameter selected for the Test Plan
  • triggeredType: Triggered type for the Test Plan whether by API or via Testsigma App
  • totalRunningCount: Total number of running tests
  • page_timeout: Global Page load timeout in seconds
  • element_timeout: Global Element load timeout in seconds
  • recovery_action: Action to be performed on test failure - "Run_Next_Testcase"
  • on_aborted_action: Action to be performed on test abort - "Reuse_Session"
  • screenshot_option: When to take screenshots - "FAILED_STEPS", “ALL_STEPS”, “NONE”
  • group_prerequisite_fail: Action to perform on Test Suite prerequisite failure
  • test_case_prerequisite_fail: Action to perform on Test Case prerequisite failure
  • test_step_prerequisite_fail: Action to perform on Test Step prerequisite failure
  • totalQueuedCount: Total number of queued tests
  • Execution Config name and ID are the saved configurations for Partial Test Plan Runs.
  • In the POST request, you can either use the name or the ID for the Execution Config.
  • Get the Execution Config ID and name via this GET Request: https://testsigma.com/docs/api/test-plans/#get-test-plan-favouritesconfig
NOTE:

All the remaining fields are either self-explanatory or can be ignored.

For a Test Plan, you can get the Test Plan ID and the complete cURL request to trigger the execution from the Test Plan Details page:

Test Plan detains inside the CICD tab of a test plan

The Run ID is returned as ‘id’ in the response for the request if the execution was started successfully.

The Environment ID is optional. To know how to get an environment id check here: Get an Environment ID

Test Plan Status

Each Test Plan Run in Testsigma has a unique Run ID. This Run ID can be used to check the live status of the Test Plan Run or Test Plan Status.

NOTE:

You need to authenticate these requests with your Testsigma API Key. See How to generate API Keys


Trigger Test Plans in Different Environments

To execute a test plan with different Environments, you need to have an Environment ID. You can find the Environment ID by following the steps below.

Get Environment ID

  1. Navigating to Test Data > Environments, and click on an Environment.
  2. On the Environment page, the <ENVIRONMENT_ID> in the URL https://app.testsigma.com/ui/td/88/environments/<ENVIRONMENT_ID>/details is the ID of the environment.

Environments

  • For Example, if the URL is https://app.testsigma.com/ui/td/88/environments/10/details, the ID is 10.

Executing Tests Plans with Different Environments

  1. Navigate to Test Plans > Test Plan > CI/CD Integrations, and copy CURL request under REST API to integrate with other tools > REST API call to start Test Plan. CURL
  2. Provide the Environment ID in the request body.
curl -X POST \
-H "Content-type: application/json" \
-H "Accept:application/json" \
-H "Authorization: Bearer <API_KEY>" \
https://app.testsigma.com/api/v1/execution_results \
-d "{\"executionId\": \"301\", \"environmentId\": \"<ENVIRONMENT_ID>\"}"

You can execute this CURL command in your computer's command-line interface (CLI) to trigger test plan with the environment specific to the given ID.


Obtaining the Run ID

If the Test Plan Run was started from within the Testsigma App, the Run ID can be found from the Run Results page as shown below:

Run IDs

The values from 295 to 299 are Run IDs of consecutive Test Plan Runs.

If the Test Plan was started by the Test Plan Trigger API Call, the Run ID can be obtained from the API Response under the JSON key ‘id’.

run ids from API response under the json key id


Test Plan Status API

This endpoint allows users to check the status of an already triggered Test Plan Run.

Request Type GET
Endpoint https://app.testsigma.com/api/v1/execution_results/<run_id>
The <run_id> can be obtained from the Run Results or API Response as mentioned above.
Authorization Bearer <api_token>
The <api_token> is the same as the Testsigma API key mentioned above.
Response Body {
 "id": 302,
 "execution": {
    "id": 274,
    "applicationVersionId": 39,
    "name": "Test Plan Trigger REST API",
    "description": null,
    "mailList": null,
    "elementTimeOut": 30,
    "pageTimeOut": 30,
    "environmentId": null,
    "screenshot": "FAILED_STEPS",
    "recoveryAction": "Run_Next_Testcase",
    "onAbortedAction": "Reuse_Session",
    "onSuitePreRequisiteFail": "Abort",
    "onStepPreRequisiteFail": "Run_Next_Testcase",
    "reRunType": "NONE",
    "executionLabType": "TestsigmaLab",
    "executionType": "CROSS_BROWSER",
    "isManual": false,
    "lastRunId": 343,
    "applicationVersion": {
    "id": 39,
    "applicationId": 25,
    "versionName": "Default Version",
    "description": null,
    "startTime": null,
    "customFields": null,
    "endTime": null,
    "application": {
    "id": 25,
    "name": "Simply Travel (Demo)_Web Application",
    "description": "",
    "customFields": "{}",
    "projectId": 11,
    "applicationType": "WebApplication",
    "project": {
    "id": 11,
    "name": "Simply Travel (Demo)",
    "description": "Demo application. Feel free to delete",
    "customFields": "{"Custom Field 1":[null,null]}",
    "hasMultipleApps": true,
    "hasMultipleVersions": true,
    "isDemo": true,
    "projectType": "WebApplication",
    "createdBy": 9,
    "updatedBy": 9,
    "createdDate": 1567751924000,
    "updatedDate": 1633635344000,
    "files": null
    },
    "createdById": 9,
    "updatedById": 9,
    "createdDate": 1567751924000,
    "updatedDate": 1568613490000
    },
    "updatedDate": null,
    "createdById": 9,
    "updatedById": null,
    "createdDate": 1567751924000
    },
    "lastRun": null,
    "slack": {
    "enabled": null,
    "channel": null,
    "user_name": null
    },
    "createdDate": 1633510913000,
    "updatedDate": 1633617938000,
    "createdById": 9,
    "updatedById": 9,
    "matchBrowserVersion": false,
    "visualTestingEnabled": false,
    "notificationStatusList": [],
    "msTeamsConnectorNotificationEnabled": false,
    "googleChatConnectorNotificationEnabled": false,
    "environments": [],
    "retrySessionCreation": false,
    "retrySessionCreationTimeout": null,
    "onTestCasePreRequisiteFail": "Abort"
},
"executionId": 274,
"startTime": 1633512584000,
"endTime": 1633512598000,
"duration": 13647,
"result": "FAILURE",
"status": "STATUS_COMPLETED",
"message": "Test plan execution failed",
"executedBy": 43,
"buildNo": "1.9.26_rc1",
"environmentId": null,
"totalCount": 1,
"failedCount": 1,
"passedCount": 0,
"abortedCount": 0,
"stoppedCount": 0,
"notExecutedCount": 0,
"preRequisiteFailedCount": 0,
"queuedCount": 0,
"isVisuallyPassed": null,
"environment": null,
"childResult": null,
"reRunParentId": null,
"reRunType": null,
"triggeredType": "API",
"totalRunningCount": 0,
"executionDetails": {
   "page_timeout": 30,
   "element_timeout": 30,
   "recovery_action": "Run_Next_Testcase",
   "on_aborted_action": "Reuse_Session",
   "screenshot_option": "FAILED_STEPS",
   "group_prerequisite_fail": "Abort",
   "test_case_prerequisite_fail": "Abort",
   "test_step_prerequisite_fail": "Run_Next_Testcase",
   "global_param_name": null
 },
"totalQueuedCount": 0
}

Request/Response fields

  • Id: ID of the Test Plan Result
  • Execution: The Test Plan details are located within the nested Execution JSON Object including the Test Plan ID as “id”, Application Version ID as "applicationVersionId”, Test Plan name as "name", Test Plan Description as "description" and so on.
  • result: Result Status of the Test Plan - QUEUED, PASSED, FAILED, ABORTED, or STOPPED
  • status: Current Status of the Test Plan creation - STATUS_CREATED
  • executedBy: ID of the executor
  • buildNo: Build Number specified in the Test Plan Trigger call
  • isVisuallyPassed: Whether visual testing passed or not. True or False.
  • environment: Environment parameter selected for the Test Plan
  • triggeredType: Triggered type for the Test Plan whether by API or via Testsigma App
  • totalRunningCount: Total number of running tests
  • page_timeout: Global Page load timeout in seconds
  • element_timeout: Global Element load timeout in seconds
  • recovery_action: Action to be performed on test failure - "Run_Next_Testcase"
  • on_aborted_action: Action to be performed on test abort - "Reuse_Session"
  • screenshot_option: When to take screenshots - "FAILED_STEPS", “ALL_STEPS”, “NONE”
  • group_prerequisite_fail: Action to perform on Test Suite prerequisite failure
  • test_case_prerequisite_fail: Action to perform on Test Case prerequisite failure
  • test_step_prerequisite_fail: Action to perform on Test Step prerequisite failure
  • totalQueuedCount: Total number of queued tests
NOTE:

All the remaining fields are either self-explanatory or can be ignored.

The Response contains a lot of information regarding the Test Plan Run. Here’s a screenshot of the relevant excerpt from the JSON Response:

example of a json response

You can see the result as FAILURE and the current status as STATUS_COMPLETED (along with other information).


GET Test Plan Favourites/Config

This endpoint allows users to get all the Test Plan Favourites/Config that have been set. To know more on how to create these Test Plan Favourites/Configurations refer to the doc here

Request Type GET
Endpoint https://app.testsigma.com/api/v1/saved_execution_configs
Authorization Bearer <api_token>
The <api_token> is the same as the Testsigma API key mentioned above.
Response Body [
{
    "id": 2,
    "name": "rest conf inc 1",
    "query": "[{"key": "suiteId", "value": [114], "operation": "NOTIN"}]",
    "executionConfigType": "SAVED
CONFIG",
    "executionConfigCondition": "EXCLUDED",
    "createdByUser": null
  },
  {
    "id": 3,
    "name": "plan o1 exclude 2",
    "query": "[{"key": "suiteId", "value": [132, 130], "operation":
"NOTIN"}]",
    "executionConfigType": "SAVED
CONFIG",
    "executionConfigCondition": "EXCLUDED",
    "createdByUser": {
      "id": 9,
      "email": "bhanu@qateamtestingsprint.com",
      "firstName": "Bhanu",
      "lastName": "prakash",
      "userName": "bhanu",
      "status": "Active",
      "isDeleted": false,
      "isAdmin": true,
      "isSuperAdmin": true,
      "userType": null,
      "isAPIUser": false,
      "isCrowdUser": false,
      "isMasked": false,
      "gdpr": false,
      "createdDate": 1657951985000,
      "updatedDate": 1657951992000,
      "createdById": null,
      "updatedById": 9,
      "privileges": [],
      "authType": null,
      "identityServiceId": "7308"
    }
  },
  {
    "id": 4,
    "name": "update inc to exc 2 suites to 3 suites",
    "query": "[{"key": "suiteId", "value": [132, 131, 130], "operation": "NOTIN"}, {"key": "reviewedBy", "value": [9], "operation": "NOTIN"}, {"key": "assignee", "value": [9], "operation": "NOTIN"}]",
    "executionConfigType": "SAVED
CONFIG",
    "executionConfigCondition": "EXCLUDED",
    "createdByUser": null
  }
]

Test Case Execution details using REST API

This endpoint allows users to get details of all Test case executions using REST API.

Request Type GET
Endpoint https://app.testsigma.com/api/v1/execution_results/986/test_case_results
Authorization Bearer <API_Token>
Same as the Testsigma API key mentioned above.
Request Body
{ 
"executionId": 268,
"executionResultId": 986,
"result": "FAILURE",
"status": "STATUS_COMPLETED",
"testCases": [
{
"testCaseId": 413,
"testCaseName": "03 data driven small",
"testCaseResultId": 7975,
"result": "FAILURE",
"isDataDrivenCase": true,
"iterationResults": [
{
"iterationResultId": 7963,
"setName": "examples",
"result": "SUCCESS"
},
{
"iterationResultId": 7976,
"setName": "travels",
"result": "FAILURE"
},
{
"iterationResultId": 7965,
"setName": "examples 1",
"result": "FAILURE"
}
],
"testSuiteId": 197,
"testSuiteName": "02 DD Small",
"testSuiteResultId": 2295,
"machineId": 414,
"machineTitle": "machine 2",
"machineResultId": 2370
}
]
}