Check Method

Applies to TestComplete 15.48, last modified on March 01, 2023

Description

Use the Check method to compare the specified web page with the HTML document stored in the WebComparison project element that corresponds to the WebComparison object. If the verification passes, the method returns True and posts a success message to the test log. Otherwise, it returns False and, by default, logs the found differences.

Using the Check method you can also update the data stored in the WebComparison element. TestComplete does this if the Update WebTesting elements option is enabled. See Modifying WebTesting Elements.

Declaration

WebComparisonObj.Check(PageObject, Timeout)

WebComparisonObj An expression, variable or parameter that specifies a reference to a WebComparison object
PageObject [in]    Optional    A Page object Default value: The Page object that is specified in the corresponding Web Comparison project element   
Timeout [in]    Optional    Integer Default value: -1   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

PageObject

Specifies the Page object that corresponds to the web page to be compared. If this parameter is not specified, TestComplete uses the Page object that is specified in the corresponding Web Comparison project element.

Timeout

The contents of some web pages are generated dynamically after the page is loaded in the browser. The Timeout parameter lets you specify the time, in milliseconds, to wait until the web page contents match the contents stored in the Web Comparison element.

By default, the Timeout is -1, which means that the waiting time is specified by the Auto-wait timeout project property. If Timeout is 0, the method does not wait and verifies PageObject immediately.

Result Value

In comparison mode, if the comparison procedure reports that the page’s contents coincide 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.

In update mode the method always returns True.

Remarks

The method compares web pages according to the properties of the appropriate Web Comparison project element. For more information on these actions, see About Web Comparison Checkpoints.

You can also use the Compare method to perform verification actions.

Example

The following code obtains the WebComparison object and compares it with the web page.

JavaScript, JScript

function WebComparisonCheck()
{

  var Browser, Page, WebObject;

  // Launches the browser
  …

  // Obtains the page with which you want to compare the stored document
  Page = Browser.Page("*");
  Page.ToURL("smartbear.com");

  // Obtains the WebComparison object
  WebObject = WebTesting.WebComparison1;

  // Compares the web page with the stored HTML document
  WebObject.Check(Page);

  …

}

Python

def WebComparisonCheck():
  # Launches the browser
  # ...
  # Obtains the page with which you want to compare the stored document
  Page = Aliases.Browser.Page("*")
  Page.ToURL("smartbear.com")
  # Obtains the WebComparison object
  WebObject = WebTesting.WebComparison1
  # Compares the web page with the stored HTML document
  WebObject.Check(Page)
  # ...

VBScript

Sub WebComparisonCheck

  Dim Browser, Page, WebObject

  ' Launches the browser
  …

  ' Obtains the page with which you want to compare the stored document
  Set Page = Browser.Page("*")
  Call Page.ToURL("smartbear.com")

  ' Obtains the WebComparison object
  Set WebObject = WebTesting.WebComparison1

  ' Compares the web page with the stored HTML document
  Call WebObject.Check(Page)

  …

End Sub

DelphiScript

procedure WebComparisonCheck();
var Browser, Page, WebObject;
begin

  // Launches the browser
  …

  // Obtains the page with which you want to compare the stored document
  Page := Browser.Page('*');
  Page.ToURL('smartbear.com');

  // Obtains the WebComparison object
  WebObject := WebTesting.WebComparison1;

  // Compares the web page with the stored HTML document
  WebObject.Check(Page);

  …

end;

C++Script, C#Script

function WebComparisonCheck()
{

  var Browser, Page, WebObject;

  // Launches the browser
  …

  // Obtains the page with which you want to compare the stored document
  Page = Browser["Page"]("*");
  Page.ToURL("smartbear.com");

  // Obtains the WebComparison object
  WebObject = WebTesting["WebComparison1"];

  // Compares the web page with the stored HTML document
  WebObject["Check"](Page);

  …

}

See Also

About Web Comparison Checkpoints
Modifying WebTesting Elements

Highlight search results