GetCaption Function

Class

AnyWin class.

Action

  • For non-HTML objects, GetCaption returns the text (up to a maximum of 255 characters) associated with the object.
  • For HTML objects, GetCaption returns the caption form of the tag (up to a maximum of 255 characters). For more information, refer to the Silk Test Classic Agent Rules for Object Recognition document. To open the document, navigate to (in Microsoft Windows 7) Start > Programs > Silk > Silk Test > Documentation > Silk Test Classic or (in Microsoft Windows 10) Start > Silk.

Syntax

sCaption = object.GetCaption ([bRawMode, bNoStaticText])
Variable Description
sCaption The object's caption. STRING.
bRawMode

Optional: BOOLEAN.

  • If TRUE, GetCaption returns platform-specific information in the caption.
  • If FALSE (the default), platform-specific information is removed from the return value.

The Open Agent always uses FALSE for this value regardless of what is specified in the script. The returned strings include trailing and leading spaces but ellipses, accelerators, and hot keys are removed.

bNoStaticText

Optional: BOOLEAN.

  • If TRUE, GetCaption returns the object's caption if there is one or the empty string if the object does not have a caption.
  • If FALSE (the default), GetCaption returns the object's caption if there is one or the prior static text if the object does not have a caption.

The Open Agent always uses FALSE for this value regardless of what is specified in the script.

Note: This argument is not supported with Version 4.0 Agents.

Notes for Non-HTML Objects

If the application does not explicitly associate a label with the object, GetCaption returns the closest static text above or to the left of the object unless bNoStaticText is TRUE, in which case GetCaption returns the empty string. For example, the caption could be the title of a dialog box, the text on a pushbutton, or the static text closest to a text box. If there is no static text, the function returns an empty string ("").

When bRawMode is TRUE, the returned string includes any trailing and leading spaces, trailing ellipses, and embedded accelerator characters. These additional characters make the strings platform-specific. When bRawMode is FALSE, the output of GetCaption does not include any special characters.

Example

STRING sTitle
sTitle = PushButton.GetCaption()