Working With Radio Groups in Desktop Windows Applications

Applies to TestComplete 15.31, last modified on March 17, 2022

While testing radio button controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

Radio button controls provide users with the ability to make a single choice from a number of alternative options. Since options represented by these controls are related, radio buttons are treated as one control. If there is a need to represent several options within one application window, radio button controls can be bound to different sets of buttons. Grouped radio buttons are displayed within panels or group boxes. If there are no panels or group boxes, it means that all of the radio buttons within the current window are treated as one control (for detailed information on how to select radio buttons, see the Selecting a Radio Button in Desktop Windows Applications topic).

There can be several radio groups within the application window, and every radio group provides a set of options for a specific property. Two or more radio buttons belonging to the same group cannot be selected simultaneously. At that, the choice you make within one group does not depend on the other groups.

Selecting a radio button within a radio group has some specific characters. Since radio groups are treated as one control, focus is set to the whole control. After setting the focus to the radio group, you can select the needed radio button within it by simulating keystrokes. For detailed information on how to simulate keystrokes, see the Simulating Keystrokes topic. Here is an example of selecting a radio button within a radio group:

JavaScript, JScript

...

myGroup.SetFocus();

Sys.Keys("[Down][Down]");

...

Python

...
myGroup.SetFocus()
Sys.Keys("[Down][Down]")
...

VBScript

...

myGroup.SetFocus

Sys.Keys "[Down][Down]"

...

DelphiScript

...

myGroup.SetFocus();

Sys.Keys('[Down][Down]');

...

C++Script, C#Script

...

myGroup["SetFocus"]();

Sys["Keys"]("[Down][Down]");

...

Note: You can move focus from one radio group to another by simulating the Tab key press. The focus is moved from the currently selected button of one radio group to the currently selected button of another group. If a button has never been focused before, it cannot be selected by simulating the Tab key.

See Also

Working With Radio Button Controls in Desktop Windows Applications
Selecting a Radio Button in Desktop Windows Applications

Highlight search results