contentText property returns the combined text of a web page object and its child objects.
It is similar to the native
innerText property in Internet Explorer or Edge and the
textContent property in Firefox, or Chrome. However,
textContent differ in whitespace representation and child node contents included, so the TestComplete
contentText property serves as a cross-browser analog of these properties. You should use the
contentText property instead of
textContent in your tests, checkpoints and Name Mapping identification properties.
|TestObj||A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section|
The property is applied to the following object:
A string containing the combined text content of the object and all of its child objects. This text includes visible elements as well as hidden ones, that is, elements with style.display="none" or style.visibility="hidden".
TestComplete generates the
contentText property value in the following way:
TestComplete analyzes the object’s DOM child nodes and finds all text nodes among them (that is, nodes with
nodeName equal to #text).
For each text node, TestComplete gets the node contents (the
nodeValue property value) and processes it as follows:
Replaces subsequent whitespace characters (spaces, tabs, non-breaking spaces, line breaks and so on) with a single space.
Trims whitespace at the beginning and the end of the value.
The resulting values (except for empty values) are combined via the line feed character:
The value of the
vbLf constant or the
Chr(10) expression in VBScript.
vcl.Chr(10) in Python
#10 in DelphiScript.
To get an object’s contents with the HTML markup, use the native
Consider the following HTML code:
<li>List <i>item 1</i></li>
<li>List <a href="http://smartbear.com">item <b>2</b></a></li>
contentText property of the
Panel object corresponding to the
DIV element returns the following value: