GetTextProp Function

Class

HtmlHeading, HtmlLink, and HtmlText.

Action

Returns the value of the text property at the specified position.

Availability

This functionality is supported only if you are using the Classic Agent.

Syntax

aPropValue = text.GetTextProp (sPropName[, iLine, iCol])
Variable Description
aPropValue The value of the property. ANYTYPE.
sPropName The name of the property. STRING.
iLine Optional: The line containing the text you want the property value of. Default is 1. INTEGER.
iCol Optional: The position of the character (starting with 1) on iLine that you want the property value of. Default is 1. INTEGER.

Notes

Use GetTextProp to get the value of a property for a specified character in a text object. These are the properties you can access:

Property Type Description
$BackColor STRING Background color: the name of the color if it matches one of the colors in the Table of colors of Silk Test Classic; otherwise a RGB value (red, green, blue).
$FontName STRING Font name
$FontSize INTEGER Font size in points
$FontStyle FONTSTYLE Font style
$TextColor STRING Text color: the name of the color if it matches one of the colors in the Table of colors of Silk Test Classic; otherwise a RGB value (red, green, blue).
If an object is defined by multiple HTML tags, then GetTextProp() returns style properties based on the value of only the style elements of the outermost tag. For example:
If your Html page contains Silk Test Classic returns
<i><p>text<p><i> $FontStyle=FS_ITALIC
but: <p><i>text<i><p> $FontStyle=normal
<span style="font-style: italic"><p>text</p></span> $FontStyle=FS_ITALIC
but: <p><span style="font-style: italic">text</span></p> $FontStyle: normal

Silk Test Classic does not consider the <i> or <span> tags when they lie inside the <p> tag, only when they lie outside the paragraph tag.

Example 1

The following example gets the font name of the fifteenth character of the description of sunglasses on the Products page of the GMO Web application.

ANYTYPE aVal
aVal = ProductsPage.SunGlassesDesc.GetTextProp("$FontName",1,15)
Print(aVal)

// Result:
// Times New Roman

Example 2

Use the return from GetTextPropList to get the values of all properties of a character.

LIST OF STRING lsProps
STRING sProp

// get list of properties
lsProps = ProductsPage.SunGlassesDesc.GetTextPropList()

// pass them one at a time to GetTextProp
for each sProp in lsProps
  Print("{sProp}:{ProductsPage.SunGlassesDesc.GetTextProp (sProp,1,15)}")

// Result:
// $BackColor: White
// $FontName: Times New Roman
// $FontSize: 12
// $FontStyle: {}
// $TextColor: Black