Selecting a Radio Button in Desktop Windows Applications

Applies to TestComplete 15.70, last modified on December 17, 2024

Radio button controls provide users with the ability to make a single choice from a number of alternative options. Radio buttons are usually grouped, and each group is treated as one control (for more information see the Working With Radio Groups in Desktop Windows Applications topic). The main feature of radio button controls is that when one radio button is selected, the other buttons of the current group cannot be selected (in other words, the choice is exclusive). For example, a group of radio buttons can provide a choice of font styles (regular, italic, bold or bold italic). The user can select only one of the styles, all the styles cannot be selected at the same time.

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.

You can select the needed radio button in the following ways:

  • By setting focus to it. You can set focus to a radio button by using the SetFocus action. The following code snippet demonstrates how to do this:

    JavaScript, JScript

    myRadioButton.SetFocus();

    Python

    myRadioButton.SetFocus()

    VBScript

    myRadioButton.SetFocus

    DelphiScript

    myRadioButton.SetFocus();

    C++Script, C#Script

    myRadioButton["SetFocus"]();

  • By using the Click or ClickButton action. The actions belong to the Win32RadioButton object, which is associated with standard radio button controls during the test run. Here is an example:

    JavaScript, JScript

    myRadioButton.Click();

    myRadioButton.ClickButton();

    Python

    myRadioButton.Click()
    myRadioButton.ClickButton()

    VBScript

    myRadioButton.Click

    myRadioButton.ClickButton

    DelphiScript

    myButton.Click;

    myButton.ClickButton;

    C++Script, C#Script

    myRadioButton["Click"]();

    myRadioButton["ClickButton"]();

See Also

Working With Radio Button Controls in Desktop Windows Applications
Determining a Radio Button's State in Desktop Windows Applications
Click Action
ClickButton Action (RadioButton Controls)

Highlight search results