wButtonText Property (Specific to Win32, MFC ToolBar and MFC MenuBar Controls)

Applies to TestComplete 15.64, last modified on June 12, 2024


Use the wButtonText property to obtain the caption of the control button specified by the Item parameter.


TestObj.wButtonText(Item, By Position)

Read-Only Property String
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Item [in]    Required    Variant    
By Position [in]    Optional    Boolean Default value: True   

Applies To

The property is applied to the following objects:

View Mode

This property is available in the Object Browser panel and in other panels and dialogs in both Basic and Advanced view modes.


The property has the following parameters:


Specifies the desired item. You can enter the item’s index (from 0) or its caption. The caption can contain asterisk (*) or question mark (?) wildcards or regular expressions. The asterisk (*) corresponds to a string of any length (including an empty string), the question mark corresponds to any single character (including none). To specify more complicated parts of a caption, use regular expressions.

The caption can be case-sensitive or case-insensitive depending on the value of the Use case-sensitive parameters project setting.

By Position

Specifies whether the Item parameter holds the item’s id or position. Possible values:

Value Description
True The button is specified by its position in the control (from 0). The total number of items on the control is given by wButtonCount.
False The button is specified by its identifier.

Property Value

A string value holding the caption of the specified control item. If the specified item is not found, wButtonText returns an empty string.


If you use Python or DelphiScript, you should enclose the parameters of the wButtonText property in square brackets: wButtonText[item, ByPosition].


To view an example that demonstrates how to use the wButtonText property, see Addressing Toolbar Buttons in Desktop Windows Applications.

See Also

Addressing Toolbar Buttons in Desktop Windows Applications
wButtonText Property (ToolBar Controls)
wEllipses Property (ToolBar and MenuBar Controls)
wButtonID Property (ToolBar and MenuBar Controls)
wButtonCount Property (ToolBar and MenuBar Controls)
wButtonPos Property (ToolBar and MenuBar Controls)

Highlight search results