XML.CreateCheckpointOptions Method

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

Use the CreateCheckpointOptions method to create a new instance of the XMLCheckpointOptions object. This object defines the options of an XML checkpoint and can then be applied when creating a new checkpoint using the CreateXML method.

Declaration

XML.CreateCheckpointOptions()

Result An XMLCheckpointOptions object

Applies To

The method is applied to the following object:

Result Value

An XMLCheckpointOptions object that provides scripting access to the comparison settings of the XMLCheckpoint project element.

Example

The following example demonstrates how to use the CreateCheckpointOptions method to create an XMLCheckpointOptions object and use it to create a new XML checkpoint.

JavaScript

function CreateXMLOptionsDemo()
{

  var XMLDoc, OptionsObj;
  // Checks if NewXMLCheckpoint already exists in the Stores | XML collection.
  if (! XML.Contains("NewXMLCheckpoint"))
    {

    // Creates an IXMLDOMDocument object
    // If you have MSXML 4:
    XMLDoc = getActiveXObject("Msxml2.DOMDocument.4.0");
    // If you have MSXML 6:
    XMLDoc = getActiveXObject("Msxml2.DOMDocument.6.0");

    XMLDoc.async = false;

    // Loads data from the XML file to the IXMLDOMDocument object.
    XMLDoc.load("D:\\Work Folder\\SampleXMLFile.xml");

    // Creates an object that will store the XML checkpoint comparison settings.
    OptionsObj = XML.CreateCheckpointOptions();

    // Specifies some of the checkpoint comparison settings.
    OptionsObj.IgnoreNodeOrder = true;
    OptionsObj.IgnoreAttributes = true;

    // Creates NewXMLCheckpoint with the specified settings.
    XML.CreateXML("NewXMLCheckpoint", XMLDoc, OptionsObj);

    }
  else
    // If the checkpoint already exists, posts an error message to the log.
    Log.Error("The NewXMLCheckpoint already exists in the Stores | XML collection.");

}

JScript

function CreateXMLOptionsDemo()
{

  var XMLDoc, OptionsObj;
  // Checks if NewXMLCheckpoint already exists in the Stores | XML collection.
  if (! XML.Contains("NewXMLCheckpoint"))
    {

    // Creates an IXMLDOMDocument object
    // If you have MSXML 4:
    XMLDoc = Sys.OleObject("Msxml2.DOMDocument.4.0");
    // If you have MSXML 6:
    XMLDoc = getActiveXObject("Msxml2.DOMDocument.6.0");

    XMLDoc.async = false;

    // Loads data from the XML file to the IXMLDOMDocument object.
    XMLDoc.load("D:\\Work Folder\\SampleXMLFile.xml");

    // Creates an object that will store the XML checkpoint comparison settings.
    OptionsObj = XML.CreateCheckpointOptions();

    // Specifies some of the checkpoint comparison settings.
    OptionsObj.IgnoreNodeOrder = true;
    OptionsObj.IgnoreAttributes = true;

    // Creates NewXMLCheckpoint with the specified settings.
    XML.CreateXML("NewXMLCheckpoint", XMLDoc, OptionsObj);

    }
  else
    // If the checkpoint already exists, posts an error message to the log.
    Log.Error("The NewXMLCheckpoint already exists in the Stores | XML collection.");

}

Python

def CreateXMLOptionsDemo():
  # Checks if NewXMLCheckpoint already exists in the Stores | XML collection.
  if not XML.Contains("NewXMLCheckpoint"):
    # Creates an IXMLDOMDocument object.
    # If you have MSXML 4:  
    # XMLDoc = Sys.OleObject["Msxml2.DOMDocument.4.0"]
    # If you have MSXML 6:  
    XMLDoc = Sys.OleObject["Msxml2.DOMDocument.6.0"]
    XMLDoc.async = False
    # Loads data from the XML file to the IXMLDOMDocument object.
    XMLDoc.load("D:\\Work Folder\\SampleXMLFile.xml")
    # Creates an object that will store the XML checkpoint comparison settings.
    OptionsObj = XML.CreateCheckpointOptions()
    # Specifies some of the checkpoint comparison settings.
    OptionsObj.IgnoreNodeOrder = True
    OptionsObj.IgnoreAttributes = True
    # Creates NewXMLCheckpoint with the specified settings.
    XML.CreateXML("NewXMLCheckpoint", XMLDoc, OptionsObj)
  else:
    # If the checkpoint already exists, posts an error message to the log.
    Log.Error("The NewXMLCheckpoint already exists in the Stores | XML collection.")

VBScript

Sub CreateXMLOptionsDemo
  Dim XMLDoc, OptionsObj

  ' Checks if NewXMLCheckpoint already exists in the Stores | XML collection.
  If Not XML.Contains("NewXMLCheckpoint") Then

    ' Creates an IXMLDOMDocument object.
    ' If you have MSXML 4:
    Set XMLDoc = Sys.OleObject("Msxml2.DOMDocument.4.0")
    ' If you have MSXML 6:
    Set XMLDoc = Sys.OleObject("Msxml2.DOMDocument.6.0")

    XMLDoc.async = False

    ' Loads data from the XML file to the IXMLDOMDocument object.
    XMLDoc.load("D:\Work Folder\SampleXMLFile.xml")

    ' Creates an object that will store the XML checkpoint comparison settings.
    Set OptionsObj = XML.CreateCheckpointOptions()

    ' Specifies some of the checkpoint comparison settings.
    OptionsObj.IgnoreNodeOrder = True
    OptionsObj.IgnoreAttributes = True

    ' Creates NewXMLCheckpoint with the specified settings.
    Call XML.CreateXML("NewXMLCheckpoint", XMLDoc, OptionsObj)

  Else
    ' If the checkpoint already exists, posts an error message to the log.
    Log.Error("The NewXMLCheckpoint already exists in the Stores | XML collection.")

  End If

End Sub

DelphiScript

procedure CreateXMLOptionsDemo();
var XMLDoc, OptionsObj;
begin

  // Checks if NewXMLCheckpoint already exists in the Stores | XML collection.
  if not XML.Contains('NewXMLCheckpoint') then
    begin

    // Creates an IXMLDOMDocument object.
    // If you have MSXML 4:
    XMLDoc := Sys.OleObject('Msxml2.DOMDocument.4.0');
    // If you have MSXML 6:
    XMLDoc := Sys.OleObject('Msxml2.DOMDocument.6.0');

    XMLDoc.async := false;

    // Loads data from the XML file to the IXMLDOMDocument object.
    XMLDoc.load('D:\Work Folder\SampleXMLFile.xml');

    // Creates an object that will store the XML checkpoint comparison settings.
    OptionsObj := XML.CreateCheckpointOptions();

    // Specifies some of the checkpoint comparison settings.
    OptionsObj.IgnoreNodeOrder := true;
    OptionsObj.IgnoreAttributes := true;

    // Creates NewXMLCheckpoint with the specified settings.
    XML.CreateXML('NewXMLCheckpoint', XMLDoc, OptionsObj);

    end
  else
    // If the checkpoint already exists, posts an error message to the log.
    Log.Error('The NewXMLCheckpoint already exists in the Stores | XML collection.');

end;

C++Script, C#Script

function CreateXMLOptionsDemo()
{

  var XMLDoc, OptionsObj;
  // Checks if NewXMLCheckpoint already exists in the Stores | XML collection.
  if (! XML["Contains"]("NewXMLCheckpoint"))
    {

    // Creates an IXMLDOMDocument object.
    // If you have MSXML 4:
    XMLDoc = Sys["OleObject"]("Msxml2.DOMDocument.4.0");
    // If you have MSXML 6:
    XMLDoc = Sys["OleObject"]("Msxml2.DOMDocument.6.0");

    XMLDoc["async"] = false;

    // Loads data from the XML file to the IXMLDOMDocument object.
    XMLDoc["load"] ("D:\\Work Folder\\SampleXMLFile.xml");

    // Creates an object that will store the XML checkpoint comparison settings.
    OptionsObj = XML["CreateCheckpointOptions"]();

    // Specifies some of the checkpoint comparison settings.
    OptionsObj["IgnoreNodeOrder"] = true;
    OptionsObj["IgnoreAttributes"] = true;

    // Creates NewXMLCheckpoint with the specified settings.
    XML["CreateXML"] ("NewXMLCheckpoint", XMLDoc, OptionsObj);

    }
  else
    // If the checkpoint already exists, posts an error message to the log.
    Log["Error"]("The NewXMLCheckpoint already exists in the Stores | XML collection.");

}

See Also

About XML Checkpoints
Stores
CreateXML Method

Highlight search results