Skip to main content
🏠Documentation|Visual Testing Using API

Last updated on : 21 Jan 2025

Visual Testing Using API

Performing Visual Testing through API

1. Authorization

This API enables users to authenticate. On successful authentication, the user will get a token.

Terminal

curl -u "email:apiKey" <Cloud_URL>/api/access

Parameters:

  • email - your email id
  • accessKey - your access key (you will get it from Account Settings -> API)

Response:

JSON

{"result":{"token":"yz8jn9********whbfgj","code":200}}

2. Get Device

Terminal

request POST <Cloud_URL>/api/devices

curl -H "Content-Type: application/json" -d '{ "token":"authToken","duration":10, "platform":"platform", "available_now":"true"}'

Parameter Description:

  • token - Authtoken (you can get this from the authenticate response)
  • duration - Duration in minutes (How many minutes you want the device for)
  • platform - Which platform devices (Android or iOS) you want to view
  • available_now - true or false. True means display the available devices and false means display all devices (including busy and available)

Response:

JSON

{
"result": {
"token": "yz8jn9********whbfgj",
"code": 200,
"models": [
{
"index": 1,
"full_name": "Apple_iPadPro3rdGen_Ios_14.6.0_3f939",
"id": 780,
"alias_name": "3f939",
"model": "iPadPro3rdGen",
"display_name": "iPad Pro 3rd Gen",
"platform": "ios",
"version": "14.6.0",
"cpu": "Octa Core",
"bucket": 4,
"manufacturer": "Apple",
"mobile_number": "",
"dpi": "xxxhdpi",
"url": "https://device.pcloudy.com/device_images/small/iPad_Pro_3rdgen.png",
"ram": 6144,
"resolution": "2048x2732",
"display_area": 12.9,
"available": true
}
]
}
}

3. Book Device

Terminal

request POST <Cloud_URL>/api/book_device

curl -H 'ContentType:application/json' -d '{"token":"authToken","duration":minutes, "id":device_id}'

Parameter Description:

  • token - Authtoken (You will get this from the authenticate response)
  • duration - Duration in minutes (How many minutes do you want to book the device for?)
  • id - Device id (You will get this from the get devices api response)

Response:

JSON

{"result":{"token":"yz8jn9k********mwhbfgj","code":200,"rid":2320557}}

4. Upload Image

Terminal

request POST <Cloud_URL>/api/v2/visual/upload-image

header 'token: ******************'
form 'file=@"/file_path"'

Parameter Description:

  • token - Authtoken (You will get this from the authenticate response)
  • Image - .png file (Image that you wish to test)

Response:

JSON

{
"requestId": "566315c0-6827-485f-9667-255c356db66d",
"statusCode": 200,
"status": "success",
"message": "image.png uploaded successfully",
"data": {
"fileId": "5566fb19-0a23-420c-8d5c-851771152594",
"filename": "image.png"
}
}

5. Get All Text of the Uploaded Image

This API is used to get all the text present in the uploaded image.

Terminal

request POST <Cloud_URL>/api/v2/ocr/text

body '{"imageId":"b23e03ce-1cf2-41ab-9e0c-b8e91b8ed384","rid":2320539}'

Parameter Description:

  • token - Authtoken (You will get this from the authenticate response)
  • ImageID - You will get this from the Upload image response (fileId)
  • Rid - You will get this using book device api

Response:

JSON

{
"requestId": "1bb75b3e-a7e9-4e82-9d5a-1a18044a65d5",
"statusCode": 200,
"status": "success",
"message": "OK",
"data": "No Service\n6:23 pm\nAA\nfacebook.com\nfacebook\nMobile number or email address\nPassword\nLog In\nForgotten password?\nor\nCreate New Account"
}

6. Verify a Word is Present in the Image

This API enables the user to check if the word is there or not in the image.

Terminal

request POST <Cloud_URL>/api/v2/ocr/text-exists

--header 'token: 75c4g6**********smkpbhdyy'
--body '{
"imageId":"5566fb19-0a23-420c-8d5c-851771152594",
"word":"amazon",
"rid":2320383
}'

Parameter Description:

  • token - Authtoken (You will get this from the authenticate response)
  • ImageID - You will get this from the Upload image response (fileId)
  • Rid - You will get this using book device api
  • word - Enter the word that you wish to verify

Response:

JSON

{
"requestId": "862e515c-9caa-4bd4-8448-b80be834650b",
"statusCode": 200,
"status": "success",
"message": "OK",
"data": false
}

7. Get the Coordinates of a Particular Word

note

There should not be space between the words.

Terminal

request POST <Cloud_URL>/api/v2/ocr/text-coordinate

--header 'token: 75c4g6*********kpbhdyy'
--data-raw '{"imageId":"97256bf5-f3dc-4098-8a65-808b2d7c874c","word": "FACEBOOK", "rid": 2320389}'

Parameter Description:

  • token - Authtoken (You will get this from the authenticate response)
  • ImageID - You will get this from the Upload image response (fileId)
  • Rid - You will get this using book device api
  • word - Enter the word that you wish to verify

Response:

JSON

{
"requestId": "862e515c-9caa-4bd4-8448-b80be834650b",
"statusCode": 200,
"status": "success",
"message": "OK",
"data": [
{
"WordText": "FACEBOOK",
"Left": 259,
"Top": 909,
"Height": 33,
"Width": 217
}
]
}
note

If the user gives any word that is not there then they will get an empty response:

JSON

{
"requestId": "7a1f7ab1-fb6f-4e23-92a2-d87dd244df2c",
"statusCode": 200,
"status": "success",
"message": "OK",
"data": []
}

8. Compare Two Images

This API is used to compare two images and find the difference between the two images.

Terminal

request POST <Cloud_URL>/api/v2/visual/image

--header 'token: 75c4g6r3********kpbhdyy'
--body '{
"firstImageId":"7f8c1426-48b0-467e-a05c-f9af917a09c8",
"secondImageId":"0e6a80da-8b34-4855-9208-961c647680d5",
"rid":2320383
}'

Parameter Description:

  • token - Authtoken (You will get this from the authenticate response)
  • First ImageID - You will get this from the Upload image response (fileId)
  • Second ImageID - You will get this from the Upload image response (fileId)
  • Rid - You will get this using book device api

Response:

JSON

{
"requestId": "276fa242-4d92-4e0f-a5da-ccb308a230e1",
"statusCode": 200,
"status": "success",
"message": "OK",
"data": "<base64>"
}
note

User needs to convert base64 to png. Differences will be highlighted.

Did this page help you?