Network Calls
There are two ways of making network calls as part of a test:
Simple
GET
requests as part of the test prompt.CURL
network 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:
Assuming the response format is a simple JSON object:
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.
In 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
CURL
commands that will be executed sequentially.Examples of typical
CURL
commands might include the following:Perform a
DELETE
request to clean a user account before initiating a test.Create a new user account and retrieve credentials to be used in the test prompt.
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:
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:
Last updated