Sending and Receiving HTTP Requests From Keyword Tests

Applies to TestComplete 15.10, last modified on December 01, 2021

This topic explains how to send HTTP requests, obtain responses from the target server, and then use the responses data in your keyword tests.

Sending Requests

To send requests in keyword tests, TestComplete provides you with the Send Request operation. To use it, follow the steps below:

  1. Open your keyword test for editing.

  2. Drag the Send Request operation from the Data Access category of the Operations panel to your test.

  3. In the opened dialog, specify the following parameters:

    • In the Method drop-down list, select one of the available request types.

    • Specify an absolute URL path to the server or resource to which you want to send the request.

    • If the target web server uses the Basic authentication, specify the user credentials in the Username and Password edit boxes.

    • Specify how the operation will check the response status code:

      • Do not perform – The operation will not check the response status code.

      • Check for success – The operation will check whether the response status code means that the request has been sent successfully (that is, the status code is from 200 to 206).

      • Check for equality – The operation will check whether the response status code equals the specified value.

      Request and Response Parameters
  4. Click Next to proceed.

  5. Specify request content.

    • Body – To specify the body content, either enter it in the edit box, or click Edit and define it in the resulting Edit Value dialog.

    • Headers – In this table, you can add headers to your request.

      Click Add to add a new header and enter its name and value in the Name and Value columns.

      Click Remove to delete the header. Click Clear to remove all the headers.

      Request Content
  6. Click Next.

  7. On the opened page, you can review added parameters and change them if needed.

  8. Click Finish to apply the changes.

    TestComplete will add the Send Request operation to your test.

    Note: If you need to set timeout values for sending and receiving requests, write a script and call it from your keyword test by using the Run Code Snippet, Run Script Routine or Run Test operations.

Working With Responses

The Send Request operation returns a response from a web server. You can use the response later in your test. For example, you can save it to a file by using the Save to File operation.

To save the response to a file

If TestComplete sends a request successfully, and the server returns an OK response, the operation will post information about the request and the response body and header to the test log. Otherwise, the operation will post an error message to the test log.

If a request fails due to the status code error, the information about it will also be posted to the test log.

Most common status codes

See Also

Sending and Receiving HTTP Requests From Script Tests
Send Request Operation

Highlight search results