API Calls with HTTPS Requests and Responses
You can Initiate API calls to:
-
Set the state of your application before starting a test
-
Clean up data that was added by a test to prevent it from accumulating over time
-
Verify the results of operations performed in your tests that cannot be verified through the UI. For example, posting a form and then verifying that the form with the correct details was recorded on the backend
-
Test the correctness of your backend APIs, ensuring they expose the correct endpoints, execute correctly, and return the proper responses, headers, and cookies
Using HTTPS Requests
You can run any standard HTTP operations in your tests, including GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, CONNECT, and TRACE. A request can specify query parameters, request body, cookies, and headers. This can be used for GDPR protection of secret data in cookies and headers.
Here are some examples of common commands that you could include in a custom flow test:
GET Requests
-
Retrieve the homepage or main resource of a website to test connectivity and ensure the server is reachable and functioning:
GET https://example.com
-
Test how the server responds to specific URL parameters:
GET URL https://example.com?arg1=val1&arg2=val2 allowing any status code
POST Requests
-
Test the server's ability to process XML data by submitting an XML payload to the server and accepting responses with status codes 200 (OK) and 201 (Created):
POST to https://example.com '<a>abc</a>' and accept the status codes 200 and 201
-
Send an XML payload to the server to test if the server can process XML data correctly.
POST to the URL https://example.com the XML '<a>abc</a>'
-
Submit JSON data to the server with the correct content type to test that the server can handle and process JSON data.
POST to https://example.com as user "adam:mypss" with header "Content-Type: application/json" with header "Accept: application/json" and body '{ "user" : "adam", "pwd" : "foo" }'
Viewing Test Responses
The test response is displayed in the preview, including the response body, response header, and response cookies.
Viewing Header Information
Click to view the header information in a popup window.
Copying Response Values
Hover over a response value to view options to copy the following information to the clipboard:
-
– Copy property value: This copies the value displayed on the screen.
For example,
"https://images.dog.ceo/breeds/sheepdog-english/n02105641_8273.jpg"
. -
– Copy property accessor: This allows you to retrieve the value of the property.
For example, {response.body.message}.
-
– Copy property checkpoints: This allows you to paste the checkpoint into a test in the correct format.
For example,
verify that {response.body.message} is "https://images.dog.ceo/breeds/sheepdog-english/n02105641_8273.jpg"
.
Following are examples of responses that you can use to insert header information in a later step in a test:
-
{response.status} - The numeric status code (for example, 200)
-
{response.statustext} - The status text (for example, OK)
-
{response.body} - The body of the response
-
{response.headers} - Case-insensitive dictionary of response headers
-
{response.cookies} - Dictionary of response cookies
For example:
type {response.headers[content-type]} in the search box
type {response.headers.content-type} in the search box
type {response.body.name} in the search box