📡Network Calls
There are two ways of making network calls as part of a test:
Simple
GETrequests as part of the test prompt.CURLnetwork requests before the test prompt execution.
Simple GET Requests as Part of the Test Prompt
GET Requests as Part of the Test PromptScenario
A typical scenario is to retrieve an OTP code to authenticate a user during a test.
Assuming there is an endpoint to retrieve an OTP code:
https://customer-api.com/fetch-otp?customer=...&apiKey=...Assuming the response format is a simple JSON object:
{
"otp_code": "123456"
}How to Make the Network Request as Part of the Test Prompt
The first step will prompt GPT Driver to initiate a network request and remember the 'otp_code' from the response. As demonstrated in the example below, you can utilize env variables (found in Settings) as part of the URL, for example, for API tokens.
1. Perform a network request to https://customer-api.com/fetch-otp?customer={{env.username}}&apiKey={{env.api-token}} with the json selector ‘otp_code’
2. Enter the remembered otp_code in the password fieldIn Step 2, you'll learn how to use the extracted data from Step 1 by simply referring to it as 'remembered'.
If you require the capability to make more complex network requests, such as POST or DELETE requests with payloads, please refer to the next section where we explain how to leverage the so-called 'pre-request' feature.
CURL Network Requests Before the Test Prompt Execution
CURL Network Requests Before the Test Prompt ExecutionIf you require greater flexibility, our system enables you to execute CURL commands before the test prompt execution, allowing you to remember values from the responses for use in your test prompt.
To utilize this option, follow these steps:
Step 1: Define the CURL command
Navigate to the 'Settings' tab within your test.
In the 'Pre-requests' section, you have the option to define multiple
CURLcommands that will be executed sequentially.Examples of typical
CURLcommands might include the following:Perform a
DELETErequest to clean a user account before initiating a test.Create a new user account and retrieve credentials to be used in the test prompt.
curl -X DELETE "https://api.example.com/users/123/order-history" -H "Authorization: Bearer {{env.apitoken}}"curl -X POST "https://api.example.com/users/create" \
-H "Content-Type: application/json" \
-d '{"userType": "premium"}'Step 2: Use the dot syntax to specify which values to remember
If your request returns values that you want to use within the test prompt, you can simply define them using a dot selector syntax.
Example response:
{
"username": "generated_user_123",
"password": "123456"
}Define the values to remember for the test prompt.

Step 3: Incorporate the remembered value into the test prompt.
Values defined in the pre-request settings can be easily referenced in the test prompt using the 'remembered' keyword.
Example:
1. Tap on the username input field
2. Type the remembered usernameLast updated