TestProject Forum

Rest API to start test on Virtual Agent

Hi, I am trying to integrate TestProject with Gitlab CI/CD. I am running into some issues while using the Rest API to kick off a test on our Virtual Agent configured on Browserstack.

I have setup the test and am able to run it manually.

I am truing the below API call:

curl -X POST "https://api.testproject.io/v2/projects/{projectId}/tests/{testId}/run" -H "accept: application/json" -H "Authorization: {apiToken}" -H "Content-Type: application/json" -d "{ \"agentId\": \"{agentId}\", \"browser\": \"chrome\"}"

However, it complains of the below:

message: The browser [Chrome] is not installed on the agent

How do I know the available browsers on a Virtual Agent? I tried to use the agents API but it returns nothing. I know it works for local or remote agents. But not VirtualAgent.

Appreciate any help in this regards.

A virtual agent is dockerized instance of TestProject agent that will be created for you every time you will execute on one of the supported the device farms, it elements the need of having local agent installed/registered.
So, it doesn’t bundled to a specific version of chrome or webdriver, and will execute on any browser defined on job based on your account license in BS/LS.

I think you get this message since you are trying to send specific generic version of chrome in your curl command without mentioning specific version.

The easiest way to make it work will be sending simple curl command to trigger the job, without specifying any parameters, this way it will take the default browsers, agents, parameters set as it was defined on the job level via UI

You can use this syntax, and replace the project ID, JOB ID, API Key with the actuals it should work for you.

curl -X POST “https://api.testproject.io/v2/projects/YOURPRJECTID/jobs/YOURJOBID/run” -H “accept: application/json” -H “Authorization: YOURAPIKEY” -H “Content-Type: application/json” -d “{}”

Great stuff!! That worked. I wasn’t thinking in terms of job. I was trying to execute the test directly. That’s where it went wrong. Its working now. Thanks a lot!