Accessing DOM document Object

Applies to TestComplete 15.64, last modified on May 16, 2024

The information in this topic applies both to cross-platform and classic web tests.

In your web tests, you can access the HTML DOM document object of web pages. You can use it in your tests to get specific DOM-related data from the web page.

To access a web page’s DOM document object, use the Page.contentDocument property. Similarly, to get the document object of a frame, use the Frame.contentDocument property.

The following example demonstrates how you can use the DOM document.title property to get the web page title:

Keyword test that gets the contentDocument.title property value

JavaScript, JScript

  var page = Sys.Browser().Page("*");


  page = Sys.Browser().Page("*")


  Set page = Sys.Browser.Page("*")
  Log.Message page.contentDocument.title


var page;
  page := Sys.Browser.Page('*'');

C++Script, C#Script

  var page = Sys["Browser"]()["Page"]("*");

For information on the properties and methods of the DOM document object in different browsers, follow these links:

Cross-Platform Web Test Limitation

In your cross-platform web tests, you can only access the DOM document object’s properties and methods that return simple type data (strings, integers, or Booleans). If a member returns a value of a complex type, for example, a collection, TestComplete will convert it into a string.


The contentDocument property is a native property of web pages in Chrome, Firefox, Edge and Internet Explorer 11.

See Also

How To
Run JavaScript on Web Pages
Access Native Web Attributes and Methods
Getting CSS Attributes

Highlight search results