Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Dec 09, 2018 09:17

Code samples

To see the full Java code sample see the executions-api-sample in the Perfecto Git repository.

Obtain a Personal Security Token

The API requires the use of the Perfecto Security Token. Follow the procedure detailed in the Security Token documentation, before proceeding.

Note: The security token is associated with the specific Perfecto Lab and the personal registered user.

Note: To use the API to view executions other than those running from his user, the Perfecto Lab user must be assigned the Admin Execution role. Please contact customer support to perform the role assignment.

Using the API

The API currently supports two operations:

  • Get Current Executions - Retrieve information regarding all currently running test executions.
  • Stop Executions - Stop all running executions for a user.

Get Current Executions

The following HTTP POST command is used to retrieve a list of the test executions in your lab:

MethodAPI
POSThttps://<executions-server>/execution-manager/api/v1/executions/search

Retrieve running executions of logged in user according to received parameters. For execution manager admin user executions of all users will be returned.

Parameters:

Parameters are added to the request in JSON format. There are three major parameters that include sub-parameters that indicate different aspects:

MajorSub-flagDescription
layout
Execution information fields to retrieve. In case no layout is provided the full execution information will be returned.

idExecution id field is included

nameTest execution name is included

ownerUser name of account running the execution.

platformsList of open devices associated with the execution.
filter
Data field values that limit the list of executions returned to those that match the filters. The execution fields that can be queried in “fields” and “excludedFields” fields are id, name and owner.

fields

Any of the fields listed above with an appropriate value to match.  Only executions whose information matches the given filters will be listed. For example, to retrieve only those executions associated with the account of user1 supply:

"filter" : {fields { "owner" : ["user1"] }}

excludedFields

Any of the fields listed above with an appropriate value to match. Only executions whose information does not match the given filters will be listed. For example, to retrieve executions whose script is not named runExample supply:

"filter" : {excludedFields { "name" : ["runExample"] }}

freeTextFilter

Value of this fields will be searched in the following fields:

    i.  Execution fields: id, name, owner

    ii. Device fields: id, device type, os name, os version

sort
Defines the sort order of the result. Contains the fields the result should be sorted and their order. The list will be sorted by the first specification and within the entries by the second.

sortByThe supported fields for sorting are id, name, owner, startTime.

sortOrderIndicates whether to sort in DESCEND or ASCEND order

Example of Parameters:

This example requests a list that includes the execution id, script name, and devices for all executions whose script name matches either scriptName1 or  scriptName2, run by user1, but not run by user2, sorted by the startTime and then by the script name. 

{
  "layout": [“id”, “name”, “devices”],
  "filter": {
    "fields": {
      "name": ["scriptName1", “scriptName2”],
     “owner”: [“user1”]
    },
   "excludedFields": {
     “owner”: [“user2”]
   },
“freeTextFilter”: “someText”
  },
  "sort": [
    {
      "sortBy": "startTime",
      "sortOrder": "DESCEND"
    },
    {
      "sortBy": "name",
      "sortOrder": "ASCEND"
    }
  ],
}

The following is a successful response:

Response Code: 200

[
    {
        "id": "tNWpYIDfNq",
        "name": "executionName1",
        "startTime": 1520789281226,
        "owner": "user1",
        "platforms": [
            {
                "id": "XQkEKGYKbU",
                "deviceType": "DESKTOP",
                "os": "Windows10",
                "osVersion": "2221",
                "screenResolution": "1600x1200",
                "location": "location1",
                "browserInfo": {
                    "browserType": "INTERNET_EXPLORER",
                    "browserVersion": "1.3"
                }
            }
        ]
    },
    {
        "id": "tNWwsfDfNq",
        "name": "executionName2",
        "startTime": 1520789245226,
        "owner": "user2",
        "platforms": [
            {
                "id": "ijzRvwSXed",
                "deviceType": "MOBILE",
                "os": "Windows10",
                "osVersion": "2221",
                "mobileInfo": {
                    "manufacturer": "manufacture",
                    "model": "model",
                    "description": "Description",
  “imei”: “23456767”,
 “imsi”: “1234567”,
 “phoneNumber”: “1234567”,
“distributor”: “Distributor”,
“firmware”: “Firmware”,
“operatorInfo”: {
     “name”: “operator name”,
     “country”: “operator country”,
     “code”: “operator code”
}
                },
                "screenResolution": "1440x2560",
                "location": "location"       
          }
        ]
    }
]

The following shows an Error Response:

Response Code: 401 UNAUTHORIZED

or

Response Code: 400 Bad Request

[
    {
        "userMessage": "Error message 1"
    },
    {
        "userMessage": "Error message 2"
    }
]

Stop Executions

The following HTTP POST command is used to retrieve a list of the test executions in your lab:

MethodAPI
POSThttps://<executions-server>/execution-manager/api/v1/executions/stop

Stop running executions of logged in user according to received filter. For execution manager admin user executions of all users will be stopped.

Parameters:

Parameters are added to the request in JSON format. There are three parameter types that indicate the executions to stop:

ParameterDescription
fields

Any of the fields listed above with an appropriate value to match.  Only executions whose information matches the given filters will be listed. For example, to stop executions associated with the account of user1 supply:

fields { "owner" : ["user1"] }
excludedFields

Any of the fields listed above with an appropriate value to match. Only executions whose information does not match the given filters will be listed. For example, to retrieve executions whose script is not named runExample supply:


excludedFields { "name" : ["runExample"] }
freeTextFilter

Value of this fields will be searched in the following fields:

    i.  Execution fields: id, name, owner

    ii. Device fields: id, device type, os name, os version

Example of Parameters:

This example requests tp stop all executions whose script name matches either scriptName1 or  scriptName2, run by user1, but not run by user2

{
    "fields": {
      "name": ["scriptName1", “scriptName2”],
      “owner”: [“user1”]
    },
   "excludedFields": {
      “owner”: [“user2”]
    },
   “freeTextFilter”: “someText”
   }

The following is a successful response:

Response Code: 200

{
    “stoppedExecutions”: [“executionId1”, “executionId2”],
    “unStoppedExecutions”: [“executionId3]
    }

The following shows an Error Response:

Response Code: 401 UNAUTHORIZED

or

Response Code: 400 Bad Request

[
    {
        "userMessage": "Error message 1"
    },
    {
        "userMessage": "Error message 2"
    }
]