Skip to main content

API

Below are the set of APIs that the SDK uses.

Note

In order to use the following APIs you will first need to get an API key from the dashboard.

Initialization

These APIs are used during driver initialization.

/ping

Used to pre-load models used within the given test.

Method : POST
Auth required : NO
Content-Type : application/json
Data

KeyRequiredTypeDesscription
api_keyTrueStringThe API key of the given user.
osTrueStringThe OS version string to indicate OS type and version.
sdk_versionTrueStringString indicating which version number of the SDK is being used.
languageTrueStringString indicating which programming language this is being called from.
test_case_nameTrueStringThe name of the given test case.

Response

KeyRequiredTypeDesscription
successTrueBooleanWas the request successful.
messageFalseStringThe server message of any error.

Examples

data = {
'api_key': "??API_KEY??",
'os': platform.platform(),
'sdk_version': '0.0.0',
'language': sys.version,
'test_case_name': 'My awesome test case'
}

requests.post('https://smartdriver.dev-tools.ai/ping', json=data)

Ingestion

These routes are used to help pre-populate model data for an existing element.

/add_action_info

Adds the bounding box coordinates for the element on a given screen. This is useful so the user doesn't need to manually draw the bounding box on the screenshot on the dashboard.

Method : POST
Auth required : NO
Content-Type : application/json
Data

KeyRequiredTypeDesscription
api_keyTrueStringThe API key of the given user.
labelTrueStringThe name of the element for the given screenshot..
screenshot_uuidTrueStringThe MD5 hash of the base64 image string.
xTrueFloatThe x coordinate, in pixels, of the upper left corner of the bounding box in the image.
yTrueFloatThe y coordinate, in pixels, of the upper left corner of the bounding box in the image.
widthTrueFloatThe width, in pixels, of the bounding box.
heightTrueFloatThe height, in pixels, of the bounding box.
retrainFalseBooleanString indicating which programming language this is being called from.
test_case_nameFalseStringThe name of the given test case.
multiplierFalseFloatThe screendensity to page size.

Response

KeyRequiredTypeDesscription
successTrueBooleanWas the request successful.
messageTrueStringThe server message of any information.

Examples

import base64
with open('screenshot.png') as image_file:
b64_screenshot = base64.b64encode(image_file.read())
screenshot_uuid =hashlib.md5(b64_screenshot).hexdigest()
data = {
'screenshot_uuid': screenshot_uuid,
'api_key': "??API_KEY??",
'label': element_name,
'x': elem.rect['x'],
'y': elem.rect['y'],
'width': elem.rect['width'],
'height': elem.rect['height'],
'test_case_name': 'My awesome test case'
}
response = requests.post('https://smartdriver.dev-tools.ai/add_action_info', json=data)

/exists_screenshot

Check if the given screenshot has already been backed up by the backend.

Method : POST
Auth required : NO
Content-Type : application/json
Data

KeyRequiredTypeDesscription
api_keyTrueStringThe API key of the given user.
screenshot_uuidTrueStringThe MD5 hash of the base64 image string.
labelTrueStringName of the element that we wish to get the bounding box for.

Response

KeyRequiredTypeDesscription
successTrueBooleanWas the request successful.
messageTrueStringThe server message of any information.
is_frozenTrueBooleanIndicate if the system is accepting additional screenshots for this label.
exists_screenshotTrueBooleanIndicates if this screenshot hash is already existing on the server, thus no need to re-upload it.

Examples

import base64
with open('screenshot.png') as image_file:
b64_screenshot = base64.b64encode(image_file.read())
screenshot_uuid =hashlib.md5(b64_screenshot).hexdigest()
data = {
'api_key': "??API_KEY??",
'screenshot_uuid': screenshot_uuid,
'label': element_name
}
response = requests.post('https://smartdriver.dev-tools.ai/exists_screenshot', json=data)
screenshot_exists = response.json()['exists_screenshot']

/upload_screenshot

Upload the given screenshot to the backend to be used for training and backup purposes.

Method : POST
Auth required : NO
Content-Type : application/json
Data

KeyRequiredTypeDescription
api_keyTrueStringThe API key of the given user.
screenshot_uuidTrueStringThe MD5 hash of the base64 image string.
screenshotTrueStringBase64 string of the screenshot.
labelTrueStringName of the element that we wish to get the bounding box for.
test_case_nameFalseStringThe name of the given test case.
is_interactiveFalseBooleanIndicating if the given screenshot is from an interactive test case.

Response

KeyRequiredTypeDesscription
successTrueBooleanWas the request successful.
messageTrueStringThe server message of any information.
screenshot_uuidFalseStringThe MD5 hash of the last screenshot.

Running

These routes are used during the execution of a test case to identify elements and status on the server.

Examples

import base64
with open('screenshot.png') as image_file:
b64_screenshot = base64.b64encode(image_file.read())
screenshot_uuid =hashlib.md5(b64_screenshot).hexdigest()
data = {
'api_key': "??API_KEY??",
'screenshot_uuid': screenshot_uuid,
'screenshot': b64_screenshot,
'label': element_name,
'test_case_name': 'My awesome test case'
}

response = requests.post('https://smartdriver.dev-tools.ai/upload_screenshot', json=data)

/detect

Check the given screenshot for the element. Core method to get the element from the screenshot.

Method : POST
Auth required : NO
Content-Type : application/json
Data

KeyRequiredTypeDesscription
api_keyTrueStringThe API key of the given user.
screenshotTrueStringBase64 string of the screenshot.
labelTrueStringName of the element that we wish to get the bounding box for.

Response

KeyRequiredTypeDesscription
successTrueBooleanWas the request successful.
labelTrueStringThe name of the label.
is_frozenTrueBooleanThe server message of any information.
predicted_elementTrueDictionaryThe server message of any information.
scoreTrueFloatThe confidence of the prediction (0-1.0).

Examples

import base64
import requests

with open('screenshot.png', 'rb') as image_file:
b64_screenshot = base64.b64encode(image_file.read()).decode('utf-8')

data = {
'api_key': "??API_KEY??",
'screenshot': b64_screenshot,
'label': element_name
}
response = requests.post('https://smartdriver.dev-tools.ai/detect', json=data).json()
if response['success']:
element_box = response['predicted_element']

/check_frozen

Check if the given element name is accepting additional training data. This is used to check before wasting time and bandwidth taking + uploading a screenshot.

Method : POST
Auth required : NO
Content-Type : application/json
Data

KeyRequiredTypeDesscription
api_keyTrueStringThe API key of the given user.
labelTrueStringName of the element that we wish to get the bounding box for.

Response

KeyRequiredTypeDesscription
successTrueBooleanWas the request successful.
labelTrueStringThe name of the label.
is_frozenTrueBooleanThe server message of any information.

Examples

data = {
'api_key': "??API_KEY??",
'label': element_name
}
response = requests.post('https://smartdriver.dev-tools.ai/check_frozen', json=data)
is_frozen = response.get('is_frozen', True)

Interactive Mode

Routes used to enable interactive mode where a user can fix any selectors where there is no existing model for.

/testcase/get_action_info

Route to check if a given screen has now been clasisifed on the server side.

Method : POST
Auth required : NO
Content-Type : application/json
Data

KeyRequiredTypeDesscription
api_keyTrueStringThe API key of the given user.
labelTrueStringName of the element that we wish to get the bounding box for.
screenshot_uuidTrueStringThe MD5 hash of the screenshot sent to the server.
run_classifierFalseBooleanWait for the classifier to be trained and executed on the screenshot before getting bounding box (default: False).

Response

KeyRequiredTypeDesscription
successTrueBooleanWas the request successful.
messageTrueStringThe server message of any error.
predicted_elementTrueJSONThe JSON object representing the bounding box of the element.
scoreTrueFloatThe prediction score for the given element on the screenshot. Used in debugging.

Examples

import base64
import time
with open('screenshot.png') as image_file:
b64_screenshot = base64.b64encode(image_file.read())
screenshot_uuid =hashlib.md5(b64_screenshot).hexdigest()
data = {
'api_key': "??API_KEY??",
'label': element_name,
'screenshot_uuid': screenshot_uuid
}

user_labeled_element = False
while user_labeled_element:
r = requests.post(self.url + '/testcase/get_action_info', json=data, verify=False).json()
# Has the element been classified by the user? If so get the element back
if r['success']:
user_labeled_element = True
element_box = r['predicted_element']
time.sleep(1)