Testcase

A Testcase is the result object of running a Case for a specific Site. Essentially, Testcases allow the user to reuse Cases for multiple Sites across the application. A Testcase contains all the same components as it's associated Case as well as expanded information for each step.

Testcase object

{
   "id":"dd1f4670-8547-4fa8-8000-55c8e2dc20be",       // uuid specific to the Testcase
   "site":"c1ebc475-b214-4a31-99f2-cb875ea1c185",     // uuid specific to the associated Site
   "time_created":"2022-06-30T16:42:33.888151Z",      // timestamp of Testcase creation
   "time_completed":"2022-06-30T16:44:00.660156Z",    // timestamp of Testcase completion
   "case":"e458dbb0-0d29-4d01-a67a-b39899614504",     // uuid specific to the associated Case
   "case_name":"contact form",                        // name of associated Case
   "passed":true,                                     // Bool noting if the Testcase passed or failed
   "tags": ["tag1", "tag2"],                          // <optional> list of info for user to track data
   "configs":{                      // configs object 
      "device":"desktop",           // either desktop or mobile
      "window_size":"1920,1080",    // dimensions of webdriver window. format -> (width,height)
      "max_wait_time":30,           // max time, in seconds, to wait for element to to be visible
      "min_wait_time":10            // time, in seconds, to wait in between each step
   },
   "steps":[
      {
         "action":{                    // action component
            "key":"",                  // key value used for "keyDown" actions - "Enter", "Tab", etc.
            "path":"/",                // path to navigate to (NOTE: all paths should be relative - no "https://example.com/")
            "type":"navigate",         // action type - "click", "navigate", "change", "keyDown" 
            "value":"",                // value you want to "change" the element to "some text"
            "passed":true,             // bool noting of the specific action passed or failed 
            "element":"",              // selector of element - "navbarSupportedContent > ul > li:nth-child(3) > a"
            "exception":null,          // exception details if the action failed
            "time_created":"2022-06-30 16:42:34.398921",   // timestamp when action started
            "time_completed":"2022-06-30 16:42:49.900984"  // timestamp when action completed
         },
         "assertion":{
            "type":"",
            "value":"",
            "passed":null,
            "element":"",
            "exception":null,
            "time_created":null,
            "time_completed":null
         }
      },
   ]
}

Create a Test

There are two endpoints for creating a Testcase. The most commonly used is the delay endpoint which allows the creation task to run asynchronously on the server and resolves quickly. Alternatively, you may use the traditional endpoint which may take several seconds to resolve as the server is actively creating a test and will return the completed Testcase object.

data in this request:

"data": {
   "site_id": "<site:id>",          // <required> uuid of the Site you want to run the Testcase for
   "case_id": "<case:id>",          // <required> uuid of the Case you want to run 
   "tags": ["tag1", "tag2"],        // <optional> list of info for user to track data
   "updates": [                        // <optional> list of changes you want to make to the Case's default values (referenced by index)
      {
         "index": 3,                   // index of the step you want to update (index = 0 is the first setp)
         "value": "jane@example.com"   // new value you want to update the action value to
      }
   ]
   "configs": {                     // <optional> configs object 
      "device":"desktop",           // either desktop or mobile
      "window_size":"1920,1080",    // dimensions of webdriver window. format -> (width,height)
      "max_wait_time":30,           // max time, in seconds, to wait for element to to be visible
      "min_wait_time":10            // time, in seconds, to wait in between each step
   },
}

WARNING

Passing the configs object is optional. However, if you do pass the object you must specify all sub-components.

POST - /testcase/delay

# import env vars
SCANERR_API_BASE_URL = os.environ.get('SCANERR_API_BASE_URL')
SCANERR_API_TOKEN = os.environ.get('SCANERR_API_BASE_URL')

# setup configs
url = f'{SCANERR_API_BASE_URL}/testcase/delay'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}
data = {
   "site_id": "<site:id>",        
   "case_id": "<case:id>",         
   "tags": ["tag1", "tag2"],        
   "updates": [                      
      {
         "index": 3,                  
         "value": "jane@example.com"  
      }
   ]
   "configs": {                     
      "device":"desktop",           
      "window_size":"1920,1080",    
      "max_wait_time":30,           
      "min_wait_time":10           
   },
}

# send the request
res = requests.post(
    url=url,
    headers=headers,
    data=json.dumps(data)
)

# retrieve response data
json_response = res.json()
print(json_response)

View Full Output

Output:


{

   "id": "dd1f4670-8547-4fa8-8000-55c8e2dc20be",
   "site": "c1ebc475-b214-4a31-99f2-cb875ea1c185",
   "time_created": "2022-06-30T16:42:33.888151Z",
   "time_completed": null,
   "case": "e458dbb0-0d29-4d01-a67a-b39899614504",
   "case_name": "contact form",
   "tags": ["tag1", "tag2"],  
   "passed": false, 
   "configs": {
      "device": "desktop",
      "window_size": "1920,1080",
      "max_wait_time": 30,
      "min_wait_time": 10
   },
   "steps": [
      {
         "action": {
            "key": "",
            "path": "/",
            "type": "navigate",
            "value": "",
            "passed": null,
            "element": "",
            "exception": null,
            "time_created": null,
            "time_completed": null
         },
         "assertion" :{
            "type": "",
            "value": "",
            "passed": null,
            "element": "",
            "exception": null,
            "time_created": null,
            "time_completed": null
         }
      },
      {
         "action": {
            "key": "",
            "path": "",
            "type": "change",
            "value": "My Company inc",
            "passed": null,
            "element": "#leadCapCompany",
            "exception": null,
            "time_created": null,
            "time_completed": null
         },
         "assertion": {
            "text": "Can we grab your info real quick?",
            "type": "match",
            "value": "Can we grab your info real quick?",
            "passed": null,
            "element": "#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1",
            "exception": null,
            "time_created": null,
            "time_completed": null
         }
      },
      # SHOETENED FOR DISPLAY PURPOSES
   ],

}

Retrieve a Testcase

This endpoint returns a single Testcase object and is useful as a simple "detailed view" of the testcase.

GET - /testcase/<testcase:id>

import requests, os

# import env vars
SCANERR_API_BASE_URL = os.environ.get('SCANERR_API_BASE_URL')
SCANERR_API_TOKEN = os.environ.get('SCANERR_API_BASE_URL')

# setup configs
url = f'{BASE_URL}/testcase/<testcase:id>'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}

# send the request
res = requests.get(
    url=url,
    headers=headers,
)

# retrieve response data
json_response = res.json()
print(json_response)

View Full Output

Output:

{
   "id": "dd1f4670-8547-4fa8-8000-55c8e2dc20be",
   "site": "c1ebc475-b214-4a31-99f2-cb875ea1c185",
   "time_created": "2022-06-30T16:42:33.888151Z",
   "time_completed": "2022-06-30T16:44:00.660156Z",
   "case": "e458dbb0-0d29-4d01-a67a-b39899614504",
   "case_name": "contact form",
   "tags": ["tag1", "tag2"],  
   "passed": true,
   "configs": {
      "device": "desktop",
      "window_size": "1920,1080",
      "max_wait_time": "30",
      "min_wait_time": 10
   },
   "steps": [
      {
         "action": {
            "key": "",
            "path": "/",
            "type": "navigate",
            "value": "",
            "passed": true,
            "element": "",
            "exception": null,
            "time_created": "2022-06-30 16:42:34.398921",
            "time_completed": "2022-06-30 16:42:49.900984"
         },
         "assertion" :{
            "type": "",
            "value": "",
            "passed": null,
            "element": "",
            "exception": null,
            "time_created": null,
            "time_completed": null
         }
      },
      {
         "action": {
            "key": "",
            "path": "",
            "type": "change",
            "value": "My Company inc",
            "passed": true,
            "element": "#leadCapCompany",
            "exception": null,
            "time_created": "2022-06-30 16:43:40.467322",
            "time_completed": "2022-06-30 16:43:50.559047"
         },
         "assertion": {
            "text": "Can we grab your info real quick?",
            "type": "match",
            "value": "Can we grab your info real quick?",
            "passed": true,
            "element": "#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1",
            "exception": null,
            "time_created": "2022-06-30 16:43:50.568624",
            "time_completed": "2022-06-30 16:43:50.579592"
         }
      },
      # SHOETENED FOR DISPLAY PURPOSES
   ],
   
}

Retrieve many Testcases

This endpoint returns a paginated response with all Testcases objects filtered by your account and ordered by time_created. This endpoint is useful when needing to displaying your testcases in a table view for example. The limit parameter specifies the total number of objects you want returned per "group" (we recomend keeping this under 10 for best performance). The offset parameter specfies which "group" to return. For example, limit=10&offset=10 in a total dataset of 30 objects would return 10 testcases in range testcase #10 - testcase #20.

TIP

Additionally, an optional parameter is site_id=<site:id> which would limit the objects filtering to the associated site.

GET - /testcase?limit=10&offset=0

import requests, os

# import env vars
SCANERR_API_BASE_URL = os.environ.get('SCANERR_API_BASE_URL')
SCANERR_API_TOKEN = os.environ.get('SCANERR_API_BASE_URL')

# setup configs
url = f'{BASE_URL}/testcase?limit=10&offset=0'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}

# send the request
res = requests.get(
    url=url,
    headers=headers,
)

# retrieve response data
json_response = res.json()
print(json_response)

View Full Output

Output:

{
   "count":30,
   "next":"https://api.scanerr.io/v1/ops/testcase?limit=10&offset=20",
   "previous":"https://api.scanerr.io/v1/ops/testcase?limit=10&offset=10", 
   "results":[
      {
         "id": "dd1f4670-8547-4fa8-8000-55c8e2dc20be",
         "site": "c1ebc475-b214-4a31-99f2-cb875ea1c185",
         "time_created": "2022-06-30T16:42:33.888151Z",
         "time_completed": "2022-06-30T16:44:00.660156Z",
         "case": "e458dbb0-0d29-4d01-a67a-b39899614504",
         "case_name": "contact form1",
         "tags": ["tag1", "tag2"],  
         "passed": true,
         "configs": {
            "device": "desktop",
            "window_size": "1920,1080",
            "max_wait_time": "30",
            "min_wait_time": 10
         },
         "steps": [
            {
               "action": {
                  "key": "",
                  "path": "/",
                  "type": "navigate",
                  "value": "",
                  "passed": true,
                  "element": "",
                  "exception": null,
                  "time_created": "2022-06-30 16:42:34.398921",
                  "time_completed": "2022-06-30 16:42:49.900984"
               },
               "assertion" :{
                  "type": "",
                  "value": "",
                  "passed": null,
                  "element": "",
                  "exception": null,
                  "time_created": null,
                  "time_completed": null
               }
            },
            {
               "action": {
                  "key": "",
                  "path": "",
                  "type": "change",
                  "value": "My Company inc",
                  "passed": true,
                  "element": "#leadCapCompany",
                  "exception": null,
                  "time_created": "2022-06-30 16:43:40.467322",
                  "time_completed": "2022-06-30 16:43:50.559047"
               },
               "assertion": {
                  "text": "Can we grab your info real quick?",
                  "type": "match",
                  "value": "Can we grab your info real quick?",
                  "passed": true,
                  "element": "#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1",
                  "exception": null,
                  "time_created": "2022-06-30 16:43:50.568624",
                  "time_completed": "2022-06-30 16:43:50.579592"
               }
            },
            # SHOETENED FOR DISPLAY PURPOSES
         ],
         
      }
      {
         "id": "dd1f4670-8547-4fa8-8000-55c8e2dc20be",
         "site": "c1ebc475-b214-4a31-99f2-cb875ea1c185",
         "time_created": "2022-06-30T16:42:33.888151Z",
         "time_completed": "2022-06-30T16:44:00.660156Z",
         "case": "e458dbb0-0d29-4d01-a67a-b39899614504",
         "case_name": "contact form2",
         "tags": ["tag1", "tag2"],  
         "passed": true,
         "configs": {
            "device": "desktop",
            "window_size": "1920,1080",
            "max_wait_time": "30",
            "min_wait_time": 10
         },
         "steps": [
            {
               "action": {
                  "key": "",
                  "path": "/",
                  "type": "navigate",
                  "value": "",
                  "passed": true,
                  "element": "",
                  "exception": null,
                  "time_created": "2022-06-30 16:42:34.398921",
                  "time_completed": "2022-06-30 16:42:49.900984"
               },
               "assertion" :{
                  "type": "",
                  "value": "",
                  "passed": null,
                  "element": "",
                  "exception": null,
                  "time_created": null,
                  "time_completed": null
               }
            },
            {
               "action": {
                  "key": "",
                  "path": "",
                  "type": "change",
                  "value": "My Company inc",
                  "passed": true,
                  "element": "#leadCapCompany",
                  "exception": null,
                  "time_created": "2022-06-30 16:43:40.467322",
                  "time_completed": "2022-06-30 16:43:50.559047"
               },
               "assertion": {
                  "text": "Can we grab your info real quick?",
                  "type": "match",
                  "value": "Can we grab your info real quick?",
                  "passed": true,
                  "element": "#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1",
                  "exception": null,
                  "time_created": "2022-06-30 16:43:50.568624",
                  "time_completed": "2022-06-30 16:43:50.579592"
               }
            },
            # SHOETENED FOR DISPLAY PURPOSES
         ],
         
      }
      
      ### SHORTENED FOR DISPLAY PURPOSES ###
      
   ]
}

Delete a Testcase

DANGER

Please use caution with this endpoint as it is irreversible.

DELETE - /testcase/<tescaset:id>

import requests, os

# import env vars
SCANERR_API_BASE_URL = os.environ.get('SCANERR_API_BASE_URL')
SCANERR_API_TOKEN = os.environ.get('SCANERR_API_BASE_URL')

# setup configs
url = f'{BASE_URL}/testcase/<testcase:id>'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}

# send the request
res = requests.delete(
    url=url, 
    headers=headers, 
)

# retrieve response data
json_response = res.json()
print(json_response)

View Full Output

Output:

    {
        "message": "testcase deleted successfully"
    }

Last Updated:
Contributors: landon