Parameterizing XML Checkpoints

Applies to TestComplete 14.60, last modified on April 22, 2021

XML checkpoints in TestComplete check the contents of a specified XML document by comparing it with the baseline copy stored in your project as an XMLCheckpoint element.

The XML checkpoint takes only one parameter - the source of XML data to be checked. This parameter can be one of the following:

  • The fully qualified name or URL of the desired XML document (it lets you compare the stored data with any XML file).

  • The IXMLDOMDocument object (it lets you compare the stored data with any XML document).

  • An XMLCheckpoint object (it lets you compare the stored data with data of another XMLCheckpoint element).

  • A WebService object (this functionality is used to create web service checkpoints).

If you want to re-use an XML checkpoint in your test, for example, to check multiple XML documents against the same baseline XML document, you can replace the hard-coded XML source with a parameter that obtains the desired XML document before the checkpoint is called. In other words, you may want to parameterize your XML checkpoint.

The image below demonstrates two XML checkpoints. One of them verifies a hard-coded XML document, the other one verifies an XML document whose source is specified in the param1 keyword test parameter.

Parameterized File Checkpoint Operation

The sections below describe how to parameterize your XML checkpoints.

In keyword tests

  1. Create a parameter that will pass the needed value to the checkpoint. It can be:

    For example, the image below shows the Param1 parameter of a keyword test:

    Creating a keyword test parameter to parameterize a checkpoint

    Click the image to enlarge it.

  2. In your keyword test, replace the hard-coded value of the checkpoint operation with the created parameter or variable:

    Parameterizing Checkpoint operation

    Click the image to enlarge it.

  3. Assign the needed value to the created parameter or variable:

    • If you use a test parameter, set its value when you run your test:

      • If you run it as part of the project’s test items sequence, set the test parameter on the Test Items page of your project:

        Setting parameter value

        Click the image to enlarge it.

      • If you run your test from another test, set the parameter value when calling your test.

    • To set a variable value, you can use the Set Variable Value operation.

  4. Run the test with the needed parameter value assigned.

In scripts

  1. Define a parameter or variable that will pass the needed value to the checkpoint. It can be:

    For example, the code snippet below shows how to declare the Param1 parameter of a script routine:

    JavaScript, JScript

    function ValidateXMLFile(Param1)
    {
      …
    }

    Python

    def ValidateXMLFile(Param1):
      …

    VBScript

    Sub ValidateXMLFile(Param1)
      …
    End Sub

    DelphiScript

    procedure ValidateXMLFile(Param1);
    begin
      …
    end;

    C++Script, C#Script

    function ValidateXMLFile(Param1)
    {
      …
    }
  2. Replace the hard-coded parameter of the XML.XML_Checkpoint_Name.Check method with the created variable or parameter:

    JavaScript, JScript

    function ValidateXMLFile(Param1)
    {
      …
      // Validate the xml file
      XML.XmlCheckpoint1.Check(Param1);
      …
    }

    Python

    def ValidateXMLFile(Param1):
      …
      # Validate the xml file
      XML.XmlCheckpoint1.Check(Param1)
      …

    VBScript

    Sub ValidateXMLFile(Param1)
      …
      ' Validate the xml file
      Call XML.XmlCheckpoint1.Check(Param1)
      …
    End Sub

    DelphiScript

    procedure ValidateXMLFile(Param1);
    begin
      …
      // Validate the xml file
      XML.XmlCheckpoint1.Check(Param1);
      …
    end;

    C++Script, C#Script

    function ValidateXMLFile(Param1)
    {
      …
      // Validate the xml file
      XML["XmlCheckpoint1"]["Check"](Param1);
      …
    }
  3. Assign the needed value to the parameter or variable:

    • If you use a script parameter, you set the parameter value when you call the script, either from another script routine or as the project’s test item.

      The image below shows how to set the parameter value when running the script routine as a project’s test item:

      Setting parameter value

      Click the image to enlarge it.

    • If you use a variable, set its value in the script before the script executes the checkpoint.

  4. Run the script with the needed parameter value assigned.

See Also

XML Checkpoints
XML Checkpoints
XML Checkpoint Operation
Check Method
Parameterizing Tests

Highlight search results