diff --git a/assets/images/kane-ai/knowledge-base/variables/json-variable.mp4 b/assets/images/kane-ai/knowledge-base/variables/json-variable.mp4 new file mode 100644 index 000000000..0cfa426ca Binary files /dev/null and b/assets/images/kane-ai/knowledge-base/variables/json-variable.mp4 differ diff --git a/assets/images/kane-ai/knowledge-base/variables/json-variable/image1.jpg b/assets/images/kane-ai/knowledge-base/variables/json-variable/image1.jpg new file mode 100644 index 000000000..1e3d1ebc6 Binary files /dev/null and b/assets/images/kane-ai/knowledge-base/variables/json-variable/image1.jpg differ diff --git a/assets/images/kane-ai/knowledge-base/variables/json-variable/image2.jpg b/assets/images/kane-ai/knowledge-base/variables/json-variable/image2.jpg new file mode 100644 index 000000000..b539eebd7 Binary files /dev/null and b/assets/images/kane-ai/knowledge-base/variables/json-variable/image2.jpg differ diff --git a/assets/images/kane-ai/knowledge-base/variables/json-variable/image3.jpg b/assets/images/kane-ai/knowledge-base/variables/json-variable/image3.jpg new file mode 100644 index 000000000..ae80357d0 Binary files /dev/null and b/assets/images/kane-ai/knowledge-base/variables/json-variable/image3.jpg differ diff --git a/assets/images/kane-ai/knowledge-base/variables/json-variable/image4.jpg b/assets/images/kane-ai/knowledge-base/variables/json-variable/image4.jpg new file mode 100644 index 000000000..f82d13e11 Binary files /dev/null and b/assets/images/kane-ai/knowledge-base/variables/json-variable/image4.jpg differ diff --git a/assets/images/kane-ai/knowledge-base/variables/json-variable/image5.jpg b/assets/images/kane-ai/knowledge-base/variables/json-variable/image5.jpg new file mode 100644 index 000000000..02b65c41f Binary files /dev/null and b/assets/images/kane-ai/knowledge-base/variables/json-variable/image5.jpg differ diff --git a/assets/images/kane-ai/knowledge-base/variables/json-variable/image6.jpg b/assets/images/kane-ai/knowledge-base/variables/json-variable/image6.jpg new file mode 100644 index 000000000..09f443801 Binary files /dev/null and b/assets/images/kane-ai/knowledge-base/variables/json-variable/image6.jpg differ diff --git a/assets/images/kane-ai/knowledge-base/variables/json-variable/image7.jpg b/assets/images/kane-ai/knowledge-base/variables/json-variable/image7.jpg new file mode 100644 index 000000000..4d4ab6b25 Binary files /dev/null and b/assets/images/kane-ai/knowledge-base/variables/json-variable/image7.jpg differ diff --git a/docs/kane-ai-using-json-variables.md b/docs/kane-ai-using-json-variables.md new file mode 100644 index 000000000..865f66107 --- /dev/null +++ b/docs/kane-ai-using-json-variables.md @@ -0,0 +1,107 @@ +--- +id: kane-ai-using-json-variables +title: KaneAI - Utilizing JSON Variables for Assertions +hide_title: false +sidebar_label: JSON Variables Guide +description: Learn how to use JSON variables in the KaneAI test cases for assertions +keywords: + - lambdatest automation + - lambdatest kaneai + - kaneai scroll elements + - kaneai sidebar scroll +url: https://www.lambdatest.com/support/docs/kane-ai-using-json-variables/ +site_name: LambdaTest +slug: kane-ai-using-json-variables/ +--- + + +This document outlines the process of using JSON variables in KaneAI to assert specific objects within an API response. The guide provides a step-by-step procedure for executing API calls, examining responses, and performing assertions on both status and body of the response. + +## Prerequisites +- Access to KaneAI platform +- Basic understanding of API testing +- Familiarity with JSON structures + +## Step 1: Understanding JSON Variable Assertions +In KaneAI, you can use JSON variables to perform detailed assertions on API responses. This allows you to validate specific objects and elements within the response structure. + +## Step 2: Initiating an API Call +- Navigate to your desired API endpoint (e.g., a pet store website) +- Configure the necessary API call parameters +- Execute the API request + +### Example Workflow: +- Select the appropriate HTTP method (GET, POST, etc.) +- Add required headers +- Input any necessary request body +- Send the request + +Image + +## Step 3: Accessing Response Variables +After executing the API call, KaneAI automatically generates variables containing: +- Response status code +- Response body +- Response headers +- Other relevant metadata + +Image + +## Step 4: Asserting Response Status +To assert the response status: + +- Use double curly braces `{{` to access the variable list +- Navigate using arrow keys to select the status variable +- Define your expected status code + +Image + +### Example: +- Expected status: 200 +- If actual status is 500, the assertion will fail + +Image + +## Step 5: Asserting Response Body +Navigate through the response body using the same double curly brace method: +- Open the variable selection menu with `{{` +- Browse to the specific JSON element you want to validate +- Create an assertion for that element + +Image + +### Example Validation: +- Check if 'dogs' element exists in the response +- Verify specific property values +- Validate nested JSON structures + +Image + +
+ +## Video Explanation + diff --git a/sidebars.js b/sidebars.js index 3fb6278a3..9352a76e4 100644 --- a/sidebars.js +++ b/sidebars.js @@ -1054,7 +1054,16 @@ module.exports = { items: [ "kane-ai-command-guide", "kane-ai-web-test-writing-guidelines", - "kane-ai-using-variables" + { + type: "category", + collapsed: true, + label: "Variables Guide", + link: { + type: "doc", + id: "kane-ai-using-variables" + }, + items: ["kane-ai-using-json-variables"] + }, ], }, {