Article Overview:
This article will cover how you can achieve the following:
Guide on the distinction between API test steps and extension-based API requests within Virtuoso.
Problem Statement:
When working with APIs in Virtuoso, users may encounter confusion regarding the differences between API test steps and extension-based API requests. Each method offers distinct advantages and limitations in terms of execution environment, browser dependencies, header management, and timeout limits. Without a clear understanding of these differences, users may face challenges in selecting the most appropriate approach for their testing needs, leading to potential inefficiencies or errors in test execution.
This article aims to clarify the functional distinctions between API test steps and extension-based API requests in Virtuoso, helping users make informed decisions for their testing scenarios.
Solution:
In Virtuoso, API calls can be made using the following options:
Option 1 - Extension-based API Request:
- Extension-based API requests work on the XHR capabilities of the browser.
- Available API calls - GET, POST, PUT, and DELETE
How to Make an Extension-Based API Request in Virtuoso:
Check Extensions:
- Verify if the necessary extensions are available in your project's Extension Manager. If not, add them as follows:
Import Extensions:
- Visit the Extension Library (extensions-library).
- Select the required extension method and click on "Add Extension".
- You will be redirected to your project. Choose the access level (Project or Organization) and click "Add".
Prepare Inputs:
- Use the store NLP to form the URL, headers, and body:
-
URL:
Store value "replace with Url" in $url -
Headers:
Store value ${"Content-Type":"application/json","Accept":"*/*"} -
Body:
Store value ${"replace body content"} in $body
Call the Extension:
- Call the extension by its name and pass the necessary inputs.
- The response will be stored in the variable $response.
Please refer to the below screenshot for example:
Option 2 - API Test Step:
- API test steps use a separate executor, distinct from the browser. This component sends requests, awaits responses, and returns them to the executing bot.
- API call command enables the user to perform API requests.
How to Make an API Test Step in Virtuoso:
Open API Manager:
- Click on the API Manager icon in the sidebar.
-
Create a folder (e.g., "Prod") by clicking "New Folder", naming it, and saving it.
Create a Request:
-
Click on "Create a request". The API builder will appear on the right side.
-
Fill in the API request name, API URL, headers, request type, body payload, and authorization (based on requirement) then click "Create"
Execute the Request:
- Click the "Send" button next to the URL field to execute the request. View the response in the Response box.
Using It as a Test Step Inside a Journey:
-
- Open the Required Journey
- Use the "API Call" command to invoke the request.
-
For example, to use the “listUsers” API in the “Prod” folder, use the syntax:
- API call prod.listUsers
Execute the Journey:
-
Run your journey to see the API call results.
For more information, please refer to our guide: API MANAGER
Main Functional Differences Between the Options :
Feature | Extension-Based API Requests | Page API Test Steps |
Execution Environment | Browser | Separate executor |
Browser Settings Impact | Subject to browser configurations (e.g., Same-Origin policy) | Independent of browser configurations |
Headers/Cookies | Automatically includes browser headers and cookies | Headers and cookies must be set explicitly |
Maximum Timeout | Up to 2 minutes | 29 seconds (platform limit, use extensions for longer) |
Comments
0 comments
Please sign in to leave a comment.