For the complete documentation index, see llms.txt. This page is also available as Markdown.

Compare Inputs

This is a pre-built Action located under the @Generic Element. The functionality of this Action in Avo Assure is to compare the input values and store the identified differences in a dynamic variable.

Syntax

Input Value: <Input(Original)>;<Input(Changed)>;<Selective/All(Optional)>

Note: Supported Inputs:

  • The action supports the following input formats:

    • .json (file or text)

    • .xml (file or text)

    • text

  • The Compare Input action supports the following input combinations for comparison:

    • File vs File: Compare content between two .json or .xml files.

    • File vs Static Input: Compare a .json or .xml file with static input content.

    • Response vs File Content: Compare an APIs response stored in a dynamic variable with a .json or .xml file.

  • During comparison, the action validates:

    • Exact match.

    • Structural or content differences.

    • Value mismatches.

    • Missing or additional content.

Argument
Description

<Input Text (Original)>

(Required)

Provide the original input text or file that needs to be compared.

<Input Text (Changed)> (Required)

Provide the updated or modified input text or file to compare with the original text.

<Selective/All(Optional)>

Provide Selective to compare specific changes or All to compare all input changes.

Output Value: <Dynamic Variable>;<Dynamic Variable>(`Optional)

Argument
Description

<Dynamic Variable> (Required)

This dynamic variable holds the result of the content comparison.

<Dynamic Variable> (Optional)

This dynamic variable stores the status as True or False.

Note: The output format for Compare Files and Compare Inputs actions is as follows:

  • For JSON and Text: The output displays the differences using the following indicators:

    • - : Indicates that a line is removed from the first input.

    • + : Indicates that a line is added in the second input.

    • ? : Indicates the delta (difference) between the two inputs.

  • For xml: \ tags will be there with the following params: The output displays XML differences using the following tags:

    • diff:update-attr : Indicates that an XML attribute is updated.

    • diff:delete : Indicates that a line is deleted.

    • diff:insert : Indicates that a line is inserted.

    • diff:delete-attr : Indicates that an XML attribute is deleted.

    • diff:add-attr : Indicates that an XML attribute is added.

Example 1: Comparing Two JSON Files

In this example, we explain how to compare the content of two JSON files.

  • Action: Compare Inputs

  • Input Value: C:\TestData\Request.json;C:\TestData\ExpectedRequest.json

    • The first argument (C:\TestData\Request.json) specifies the original JSON file.

    • The second argument (C:\TestData\ExpectedRequest.json) specifies the JSON file to compare.

  • Output Value: {ComparisonResult}

    • The first output variable ({ComparisonResult}) stores the comparison result.

    • If a second output variable is provided, the action returns the status as True or False:

      • True: If the comparison executes successfully.

      • False: If the comparison fails due to invalid file path, missing file, or unsupported format.

  • Logical Explanation: The Compare Inputs action takes the values from the Input Value column (C:\TestData\Request.json;C:\TestData\ExpectedRequest.json) and compares both JSON files. The action validates the file content, structure, missing fields, additional fields, and value differences. The comparison result is stored in the {ComparisonResult} variable.

Example 2: Comparing an XML File with Static Input

In this example, we explain how to compare an XML file with static input content.

  • Action: Compare Inputs

  • Input Value: C:\Users\Downloads\Test.xml;<xml_input>

    • The first argument (C:\Users\Downloads\Test.xml) specifies the XML file to compare.

    • The second argument (<xml_input>) specifies the static XML input content.

  • Output Value: {ComparisonResult}

    • The first output variable ({ComparisonResult}) stores the comparison result.

    • If a second output variable is provided, the action returns the status as True or False:

      • True: If the comparison executes successfully.

      • False: If the comparison fails due to invalid file path, missing file, or unsupported format.

  • Logical Explanation: The Compare Inputs action takes the values from the Input Value column (C:\Users\Downloads\Test.xml;<xml_input>) and compares the XML file content with the provided static input. The action validates the structure, content, missing tags, and mismatched values. The comparison result is stored in the {ComparisonResult} variable.

Note: After executing the Test Steps, you can see the result in the Avo Assure Client console.

Example 3: Comparing Inputs Using Selective Comparison

In this example, we explain how to compare only the modified content between two inputs using Selective comparison.

  • Action: Compare Inputs

  • Input Value: {"Name":"John","Age":25,"City":"Mumbai"};{"Name":"John","Age":28,"City":"Mumbai"};Selective

    • The first argument ({"Name":"John","Age":25,"City":"Mumbai"}) specifies the original input content.

    • The second argument ({"Name":"John","Age":28,"City":"Mumbai"}) specifies the changed input content to compare.

    • The third argument (Selective) specifies that the action compares only the modified content instead of the complete structure.

  • Output Value: {ComparisonResult};{Status}

    • The first output variable ({ComparisonResult}) stores the comparison result.

    • The second output variable ({Status}) stores the execution result with the following possible values:

      • True: If the comparison executes successfully.

      • False: If the comparison fails due to invalid input, missing values, or unsupported format.

  • Logical Explanation: The Compare Inputs action takes the values from the Input Value column ({"Name":"John","Age":25,"City":"Mumbai"};{"Name":"John","Age":28,"City":"Mumbai"};Selective) and compares only the modified content between both inputs. In this example, the action identifies that the Age value changes from 25 to 28 while the remaining content stays unchanged. The comparison result is stored in the {ComparisonResult} variable as (

    - {"Name":"John","Age":25,"City":"Mumbai"} ? ^

    + {"Name":"John","Age":28,"City":"Mumbai"} ? ^

    ).

Note: Use Selective comparison when you want to validate only the changed values between inputs instead of comparing the complete content or structure.

Last updated