Latest post from this blog

Test Scenarios vs. Test Cases: Understanding the Basics

What Are Test Scenarios Test scenarios represent high-level ideas or conditions that need to be validated to ensure the application works as expected. They provide a broader perspective and are typically used during the test planning phase. Purpose: To capture the "what to test" without going into granular details. Example of a Test Scenario: Verify that a user can successfully log in to the application using valid credentials. Verify the behavior of the login page when invalid credentials are entered. Verify the application behavior when the login button is clicked without entering any credentials. What Are Test Cases Test cases are detailed documents that define the specific steps to execute a test. They cover inputs, execution steps, expected results, and actual outcomes. Purpose: To guide the tester step-by-step on "how to test." Example of a Test Case (for the first scenario): Test Case ID TC_01_Login_Valid_Credentials Test Scenario Verify user login with val...

Use of Dynamic Variables in Datadog Synthetic API Tests

Use of Dynamic Variables in Datadog Synthetic API Tests
In Datadog, Dynamic Variables are placeholders that can be used to reference values obtained from previous steps in your API test or predefined values like timestamp, random values, etc. These can be considered similar to "local variables."  

Steps to Use Dynamic Variables:
1. Create a Synthetic API Test:
   - Go to Synthetic > API Tests in Datadog.  
   - Click on Create Test and select API Test.  

2. Set Up API Test Steps:
   - In the Test Steps, configure the API call you want to test.  
   - You can define various API requests (e.g., GET, POST, PUT, etc.) and set the request headers, body, and parameters.  

3. Use Dynamic Variables:
   - Datadog allows you to use dynamic variables within your API test configuration.  

    Some examples include:  
     - {{uuid}} : Generates a random UUID for use in API parameters or headers.  

     -  {{timestamp}} : Inserts the current timestamp.  

     -  {{random}} : Generates a random number within a specified range. 

Example 1: Using Dynamic Variables with Local Scope

Scenario: send a name field  with a timestamp and another name field with a random 5 - Character string, using them as local variables for a POST request.

Step 1: Dynamic Variables 
In Datadog, you can use Dynamic Variables like {{timestamp}} or {{random}} directly in the API test configuration. These will serve as your inbuilt variables.  Automatically generated by Datadog and can be directly used in test steps.

Step 2: POST Call with name and timestamp

Endpoint:
https://api.createusers.com/user

Request Type:
POST

Header:
{
  "Content-Type": "application/json"
}

Body:

{
  "name": "User_{{timestamp}}",  
  "email": "user_{{timestamp}}@example.com",
  "unique_name": "User_{{random | string(5)}}",
  "role": "test-user"
}

Another way we can add the timestamp, character and numeric etc

Step 1: Create the Local Variables

I will create a local variable named TESTING and assign it the value timestamp. After saving the local variable, I will use the same variable in the POST call.


Body:

{
  "name": "User_{{TESTING}}",  
  "email": "abc@gmail.com"
  "role": "test-user"
}
  • {{timestamp}} will be used to generate a dynamic name with the current timestamp.
  • {{random | string(5)}} will create a 5-character random string to use for unique_name.

Comments

Popular posts from this blog

Common Exception in Selenium

Test Scenarios vs. Test Cases: Understanding the Basics

Handling Shadow DOM in Selenium WebDriver

Handling HTTPS Websites and SSL Certificate Errors in Selenium

Normalize-space Function In Xpath