Submit visual data via api
Below, you can find the steps for submitting visual data via API
Step 1: Create a build item
First, it’s necessary to create a build, which will contain the general information about a group of images for an application build.
Here is an example of a cURL request for this:
curl --location 'https://visual.mobitru.com/billing/unit/<BILLING_UNIT>/api/v1/builds' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <ACCESS_KEY>' \
--data '{
"name": "Build 1",
"project": "Test Automation Demo",
"branch": "main"
}'Below you can find a sample of the response with an ID of the created build:
{
"id": "6251a5a8-2060-4714-bf23-dfb67080c424",
"name": "Build 1",
"project": "Test Automation Demo",
"branch": "main",
"status": "running",
"createdAt": "....",
"updatedAt": "...."
}Step 2: Upload snapshots to build
After creating a Build, visual snapshots can be submitted to perform the comparison.
The following metadata can be provided with an image file:
- name – a keyword, which will identify the uploaded image
- testName – a test name, which will be used as an additional image identifier
- suiteName – a suite name for a group of tests.
- browser – a keyword, which will be related to some browser type, like chrome
- browserVersion – a keyword, which will be related to some browser version, like latest
Here is an example of a cURL request for uploading a single snapshot:
curl --location 'https://visual.mobitru.com/billing/unit/<BILLING_UNIT>/api/v1/builds/<BUILD_ID>/snapshots' \
--header 'Authorization: Bearer <ACCESS_KEY>' \
--form 'name="snapshot_name_for_page_one"' \
--form 'testName="demo_test_1"' \
--form 'suiteName="Automation Demo"' \
--form 'browser="chrome"' \
--form 'browserVersion="latest"' \
--form 'image=@"<PATH_TO_IMAGE>/<IMAGE_NAME>.png"'Below you can find a sample of the response with an ID of the uploaded snapshot:
{
"id": "a6b66613-337e-4a18-a405-c06864387fe5",
"buildId": "6251a5a8-2060-4714-bf23-dfb67080c424",
"name": "result_after_checkBrowserLocale",
"testName": "checkBrowserLocale",
"suiteName": "Automation Demo",
"browser": "chrome",
"browserVersion": "latest",
"imageRef": "916f0549-4ddc-491a-9fe7-3f27597fd3b7/bc2d6a2e-55d8-4da6-b1a8-92a66e38d1f6.png",
"createdAt": "....",
"updatedAt": "...."
}Step 3: Finish the build
After uploading of snapshots, it’s necessary to finish the build to trigger the comparison.
Here is an example of a cURL request:
curl --location --request POST 'https://visual.mobitru.com/billing/unit/<BILLING_UNIT>/api/v1/builds/<BUILD_ID>/finish' \
--header 'Authorization: Bearer <ACCESS_KEY>'Below you can find a sample of the response, which indicates that the build is finished and the comparison process is triggered:
{
"message": "Build finished successfully"
}