Check Method

Applies to TestComplete 15.68, last modified on October 03, 2024

Description

Use the Check method to compare the data stored in the XMLCheckpoint project element, which the XMLCheckpointObj object corresponds to, with the data of an XML document.

Using the Check method you can also update the XML data stored in the XMLCheckpoint element. TestComplete does this if the Update XML data option is enabled. See Modifying Elements of the XML Collection.

Declaration

XMLCheckpointObj.Check(xmlSource)

XMLCheckpointObj An expression, variable or parameter that specifies a reference to an XMLCheckpoint object
xmlSource [in]    Required    Variant    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

xmlSource

This parameter specifies the source of the compared XML data. This can be one of the following:

  • The fully qualified file name of the needed XML document.

  • The URL of the needed XML document.

  • An XMLCheckpoint object.

  • An IXMLDOMDocument object (It is an object from Microsoft XML DOM. See the DOMDocument article in the MSDN library for more information).

  • A WebService object.

Result Value

If the content of the XML document coincides with the saved baseline copy, the method returns True and posts a checkpoint message ( ) to the test log. Otherwise, the method returns False and posts an error message ( ) to the log.

Remarks

The Check method returns True or False indicating comparison results. If the verification passes, the method posts a success message to the test log. If the verification fails, the method posts all found differences to the test log.

The method compares XML data according to the comparison settings specified in the XMLCheckpoint project element. Before calling the method, you can modify these options as well as the stored data. You can find more information on changing the settings and data in Creating XML Checkpoints.

By default, if the Check method cannot find or access the XML document whose content is to be compared, or if the document does not match its baseline copy, the method will wait for the document to become accessible and for the comparison to complete successfully for the period the Auto-wait timeout setting specifies. (Go to Tools > Current Project Properties > Playback to view or modify the setting.) If the method does not access the XML document, or if the document content does not match its baseline copy within this period, the comparison will fail.

You can also use the Compare method for comparison.

Example

The following example demonstrates how you can compare the stored XML document with an external XML document specified by its full name and path.

JavaScript, JScript

function XMLCheckpointCheck()
{

  var XMLCheckpoint, XMLFile;
  // Specifies the external XML file.
  XMLFile = "D:\\Work Folder\\SampleXMLFile.xml";
  // Obtains the XMLCheckpoint object from script.
   XMLCheckpoint = XML.MyXMLCheckpoint;

  // Compares the stored XML document with the external XML document.
  XMLCheckpoint.Check(XMLFile)

}

Python

def XMLCheckpointCheck():
  # Specifies the external XML file. 
  XMLFile = "D:\\Work Folder\\SampleXMLFile.xml"
  # Obtains the XMLCheckpoint object from script. 
  XMLCheckpoint = XML.MyXMLCheckpoint
  # Compares the stored XML document with the external XML document. 
  XMLCheckpoint.Check(XMLFile)

VBScript

Sub XMLCheckpointCheck
  Dim XMLCheckpoint, XMLFile

  ' Specifies the external XML file.
  XMLFile = "D:\Work Folder\SampleXMLFile.xml"
  ' Obtains the XMLCheckpoint object from script.
  Set XMLCheckpoint = XML.MyXMLCheckpoint

  ' Compares the stored XML document with the external XML document.
  XMLCheckpoint.Check(XMLFile)

End Sub

DelphiScript

procedure XMLCheckpointCheck();
var XMLCheckpoint, XMLFile;
begin

  // Specifies the external XML file.
  XMLFile := 'D:\Work Folder\SampleXMLFile.xml';
  // Obtains the XMLCheckpoint object from script.
  XMLCheckpoint := XML.MyXMLCheckpoint;

  // Compares the stored XML document with the external XML document.
  XMLCheckpoint.Check(XMLFile);

end;

C++Script, C#Script

function XMLCheckpointCheck()
{

  var XMLCheckpoint, XMLFile;
  // Specifies the external XML file.
  XMLFile = "D:\\Work Folder\\SampleXMLFile.xml";
  // Obtains the XMLCheckpoint object from script.
   XMLCheckpoint = XML["MyXMLCheckpoint"];

  // Compares the stored XML document with the external XML document.
  XMLCheckpoint["Check"](XMLFile)

}

The following example demonstrates how you can load XML data to the IXMLDOMDocument object and compare this data with the stored XML data.

JavaScript

function XMLCheckpointCheck()
{

  var XMLDoc, XMLCheckpointObject;
  // Creates an object implementing the IXMLDOMDocument interface
  // If you have MSXML 4:
  Doc = getActiveXObject("Msxml2.DOMDocument.4.0");
  // If you have MSXML 6:
  Doc = getActiveXObject("Msxml2.DOMDocument.6.0");

  XMLDoc = getActiveXObject("Msxml2.DOMDocument.6.0")

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

  // Obtains the XMLCheckpoint object from script.
  XMLCheckpointObject = XML.MyXMLCheckpoint;

  // Compares MyXMLCheckpoint with the IXMLDOMDocument object.
  XMLCheckpointObject.Check(XMLDoc);

}

JScript

function XMLCheckpointCheck()
{

  var XMLDoc, XMLCheckpointObject;
  // Creates an object implementing the IXMLDOMDocument interface
  // If you have MSXML 4:
  Doc = Sys.OleObject("Msxml2.DOMDocument.4.0");
  // If you have MSXML 6:
  Doc = Sys.OleObject("Msxml2.DOMDocument.6.0");

  XMLDoc = Sys.OleObject("Msxml2.DOMDocument.6.0")

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

  // Obtains the XMLCheckpoint object from script.
  XMLCheckpointObject = XML.MyXMLCheckpoint;

  // Compares MyXMLCheckpoint with the IXMLDOMDocument object.
  XMLCheckpointObject.Check(XMLDoc);

}

Python

def XMLCheckpointCheck2():
  # Creates an object implementing the IXMLDOMDocument interface. 
  # If you have MSXML 4:  
  Doc = Sys.OleObject["Msxml2.DOMDocument.4.0"]
  # If you have MSXML 6:  
  Doc = Sys.OleObject["Msxml2.DOMDocument.6.0"]
  XMLDoc = Sys.OleObject["Msxml2.DOMDocument.6.0"]
  XMLDoc.async = False
  # Loads the data to the IXMLDOMDocument object from the XML document. 
  XMLDoc.load("D:\\Work Folder\\SampleXMLFile.xml")
  # Obtains the XMLCheckpoint object from script. 
  XMLCheckpointObject = XML.MyXMLCheckpoint
  # Compares MyXMLCheckpoint with the IXMLDOMDocument object. 
  XMLCheckpointObject.Check(XMLDoc)

VBScript

Sub XMLCheckpointCheck
  Dim XMLDoc, XMLCheckpointObject

  ' Creates an object implementing the IXMLDOMDocument interface.
  ' 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 the data to the IXMLDOMDocument object from the XML document.
  Call XMLDoc.load("D:\Work Folder\SampleXMLFile.xml")

  ' Obtains the XMLCheckpoint object from script.
  Set XMLCheckpointObject = XML.MyXMLCheckpoint

  ' Compares MyXMLCheckpoint with the IXMLDOMDocument object.
  Call XMLCheckpointObject.Check(XMLDoc)

End Sub

DelphiScript

procedure XMLCheckpointCheck();
var XMLDoc, XMLCheckpointObject;
begin

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

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

  // Obtains the XMLCheckpoint object from script.
  XMLCheckpointObject := XML.MyXMLCheckpoint;

  // Compares MyXMLCheckpoint with the IXMLDOMDocument object.
  XMLCheckpointObject.Check(XMLDoc);

end;

C++Script, C#Script

function XMLCheckpointCheck()
{

  var XMLDoc, XMLCheckpointObject;
  // Creates an object implementing the IXMLDOMDocument interface.
  // 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 the data to the IXMLDOMDocument object from the XML document.
  XMLDoc["load"]("D:\\Work Folder\\SampleXMLFile.xml")

  // Obtains the XMLCheckpoint object from script.
  XMLCheckpointObject = XML["MyXMLCheckpoint"];

  // Compares MyXMLCheckpoint with the IXMLDOMDocument object.
  XMLCheckpointObject["Check"](XMLDoc);

}

See Also

About XML Checkpoints
Creating XML Checkpoints
Options Property
Document Property

Highlight search results