Case

A Case is used to store a list of instructions, called steps which are utilized by the Testcase object during a run. Each step contains two primary subcomponents:

  1. action -> an object which describes the action to be taken, e.g. "click", "navigate", "change" etc.
  2. assertion -> an object which describes an assertion to be tested e.g. "match", "exists"

Case object

{
   "id":"e458dbb0-0d29-4d01-a67a-b39899614504",    // uuid specific to the case
   "name":"contact form",                          // <required> desctiptive name 
   "time_created":"2022-06-30T14:41:14.541196Z",   // timestamp of Case creation
   "tags": [null],      // <optional> optional tags object
   "steps":[            // array of step objects
      {
         "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"
            "element":""         // selector of element - "navbarSupportedContent > ul > li:nth-child(3) > a"
         },
         "assertion":{           // assertion component
            "type":"",           // assertion type - "match" or "exists"
            "value":"",          // value to "match" elemenmt to 
            "element":""         // selector of element - "navbarSupportedContent > ul > li:nth-child(3) > a"
         }
      },
      {
         "action":{
            "key":"",
            "path":"",
            "type":"change",
            "value":"My Company inc",
            "element":"#leadCapCompany"
         },
         "assertion":{
            "text":"Can we grab your info real quick?",
            "type":"match",
            "value":"Can we grab your info real quick?",
            "element":"#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1"
         }
      },
   ],
   

}

Create a Case

Use this endpoint to create or update a Case object. If you want to update an existing Case, just include the case_id parameter in the data payload.

data in this request:

"data": {
   "name":"contact form",     // <required> desctiptive name 
   "tags": ["tag1", "tag2"],  // <optional> list of info for user to track data
   "steps":[                  // array of step objects
      {
         "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"
            "element":""         // selector of element - "navbarSupportedContent > ul > li:nth-child(3) > a"
         },
         "assertion":{           // assertion component
            "type":"",           // assertion type - "match" or "exists"
            "value":"",          // value to "match" elemenmt to 
            "element":""         // selector of element - "navbarSupportedContent > ul > li:nth-child(3) > a"
         }
      },

      // SHOETENED FOR DISPLAY PURPOSES
   ]
}

POST - /case

# 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}/case'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}
data = {
   "name": "contact form",  
   "tags": ["tag1", "tag2"],
   "steps":[
      {
         "action":{              
            "key":"",            
            "path":"/",          
            "type":"navigate",   
            "value":"",         
            "element":""        
         },
         "assertion":{          
            "type":"",          
            "value":"",          
            "element":"" 
         }
      },

      # SHOETENED FOR DISPLAY PURPOSES
   ]

}

# 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":"e458dbb0-0d29-4d01-a67a-b39899614504",
   "time_created":"2022-06-30T14:41:14.541196Z",
   "tags": ["tag1", "tag2"],
   "name":"siterack form",
   "steps":[
      {
         "action":{
            "key":"",
            "path":"/",
            "type":"navigate",
            "value":"",
            "element":""
         },
         "assertion":{
            "type":"",
            "value":"",
            "element":""
         }
      },
      {
         "action":{
            "key":"",
            "path":"",
            "type":"change",
            "value":"My Company inc",
            "element":"#leadCapCompany"
         },
         "assertion":{
            "text":"Can we grab your info real quick?",
            "type":"match",
            "value":"Can we grab your info real quick?",
            "element":"#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1"
         }
      },
      
      # SHOETENED FOR DISPLAY PURPOSES
   ],

}

Retrieve a Case

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

GET - /case/<case: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}/case/<case: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":"e458dbb0-0d29-4d01-a67a-b39899614504",
   "time_created":"2022-06-30T14:41:14.541196Z",
   "tags": ["tag1", "tag2"],
   "name":"siterack form",
   "steps":[
      {
         "action":{
            "key":"",
            "path":"/",
            "type":"navigate",
            "value":"",
            "element":""
         },
         "assertion":{
            "type":"",
            "value":"",
            "element":""
         }
      },
      {
         "action":{
            "key":"",
            "path":"",
            "type":"change",
            "value":"My Company inc",
            "element":"#leadCapCompany"
         },
         "assertion":{
            "text":"Can we grab your info real quick?",
            "type":"match",
            "value":"Can we grab your info real quick?",
            "element":"#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1"
         }
      },
      
      # SHOETENED FOR DISPLAY PURPOSES
   ],
}

Retrieve many Cases

This endpoint returns a paginated response with all Cases objects filtered by your account and ordered by time_created. This endpoint is useful when needing to displaying your cases 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 cases in range case #10 - case #20.

GET - /case?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}/case?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/case?limit=10&offset=20",
   "previous":"https://api.scanerr.io/v1/ops/case?limit=10&offset=10", 
   "results":[
      {
         "id":"e458dbb0-0d29-4d01-a67a-b39899614504",
         "time_created":"2022-06-30T14:41:14.541196Z",
         "tags": ["tag1", "tag2"],
         "name":"siterack form1",
         "steps":[
            {
               "action":{
                  "key":"",
                  "path":"/",
                  "type":"navigate",
                  "value":"",
                  "element":""
               },
               "assertion":{
                  "type":"",
                  "value":"",
                  "element":""
               }
            },
            {
               "action":{
                  "key":"",
                  "path":"",
                  "type":"change",
                  "value":"My Company inc",
                  "element":"#leadCapCompany"
               },
               "assertion":{
                  "text":"Can we grab your info real quick?",
                  "type":"match",
                  "value":"Can we grab your info real quick?",
                  "element":"#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1"
               }
            },
         ],
      },
      {
         "id":"e458dbb0-0d29-4d01-a67a-b39899614504",
         "time_created":"2022-06-30T14:41:14.541196Z",
         "tags": ["tag1", "tag2"],
         "name":"siterack form2",
         "steps":[
            {
               "action":{
                  "key":"",
                  "path":"/",
                  "type":"navigate",
                  "value":"",
                  "element":""
               },
               "assertion":{
                  "type":"",
                  "value":"",
                  "element":""
               }
            },
            {
               "action":{
                  "key":"",
                  "path":"",
                  "type":"change",
                  "value":"My Company inc",
                  "element":"#leadCapCompany"
               },
               "assertion":{
                  "text":"Can we grab your info real quick?",
                  "type":"match",
                  "value":"Can we grab your info real quick?",
                  "element":"#layoutDefault_content > main > header > div.page-header-content > div > div > div:nth-child(1) > h1"
               }
            },
         
         ],
      }
            
      ### SHORTENED FOR DISPLAY PURPOSES ###
      
   ]
}

Delete a Case

DANGER

Please use caution with this endpoint as it is irreversible.

DELETE - /case/<case: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}/case/<case: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": "case deleted successfully"
    }

Last Updated:
Contributors: landon