GET/hosts/{HostId}/runs/{RunId}/items/{SequenceNumber}/script

Applies to QAComplete 14.5, last modified on August 06, 2024

Returns an automation script assigned to the test.

After an agent finds tests to be run on its host, the agent can download automation scripts to run locally.

Automation scripts are specified on the Automation tab of a test in Test Management > Test Library. Users can store automation scripts in several ways:

  • A zipped script attached to a test in the Test Library.

  • A zipped script on a web site.

  • An unpacked or zipped script in a shared network folder (UNC path).

  • An unpacked or zipped script in a local folder on the host.

The operation lets you get the automation script regardless of where it resides.

Authentication

Basic authentication using the host ID and security token. See Authentication for details.

Request Format

To download the automation script for a test, send a GET request to the following URL:

http://{server}/rest-api/service/automation/v2/hosts/{HostId}/runs/{RunId}/items/{SequenceNumber}/script?agent={Agent}

HostId  :  integer, required

The host ID.

RunId  :  integer, required

The test run ID. This is the results[index].id value from the …/currentruns operation response. In QAComplete, test run IDs appear in Test Management > Run History and in the history of Test Schedules.

SequenceNumber  :  integer, required

For test sets, this is the 1-based index (the sequence number) of the test in the set. For individual tests, use 1.

You can get this value from the response of the …/currentruns operation as results[index].test_run_items[index]. test_run_results[index].sequence_number.

Agent  :  string, required

The URL-encoded name of the agent (test runner).

REST API v2 supports the following agents:

Agent URL-encoded Name
TestComplete/TestExecute TestComplete%2FTestExecute
JUnit (Selenium) JUnit%20%28Selenium%29
NUnit (Selenium) NUnit%20%28Selenium%29
TestNG (Selenium) TestNG%20%28Selenium%29
ReadyAPI / SoapUI OS ReadyAPI+%2F+SoapUI+OS

A sample request:

GET http://yourserver.com/rest-api/service/automation/v2/hosts/143/runs/529/items/1/script?agent=TestComplete%2FTestExecute HTTP/1.1
Host: yourserver.com
Connection: keep-alive
Accept: application/zip
Authorization: Basic am9obkBleGFtcGxlLmNvbTpwQHNzd29yZA==

A sample request made by using cURL:

curl -u &id-token; -L -o testproject.zip http://yourserver.com/rest-api/service/automation/v2/hosts/143/runs/529/items/1/script?Agent=TestComplete%2FTestExecute

Response Format

The response depends on whether the automation script is attached to the test in QAComplete, or whether it is specified by using a URL or UNC path:

  • If the automation script is attached to the test, the API responds with HTTP status code 200 and returns the ZIP file contents in the response body.

    HTTP/1.1 200 OK
    Transfer-Encoding: chunked
    Content-Type: application/zip
     
    PK… 
  • If the automation script is specified by the UNC path, the API responds with HTTP status code 404 and returns the UNC path in the Location header:

    HTTP/1.1 404 NotFound
    Location: file:///\\testserver\regtests\logintest.zip

    The Location value can be either a ZIP file name, or a folder that contains the project suite files. You need to check the path type and process the path appropriately.

  • If the automation script is specified by URL, the API returns a 302 redirect with the URL in the Location header.

    HTTP/1.1 302 Found
    Location: http://testserver.example.com/regtests/logintest.zip

    Some tools and development libraries can automatically follow 302 redirects and will return the target file without having to make an extra request.

If the operation fails, it returns the appropriate status code and (optionally) the error description in the response body.

See Also

QAComplete Test Automation REST API Reference

Highlight search results