Selecting a Radio Button

Applies to TestComplete 15.47, last modified on January 20, 2023
Simulating Touch Action

To select a radio button, use the Touch or TouchButton action of the Android RadioButton object that TestComplete associates with that control. This action performs a single short touch on the control. The following example demonstrates how to touch the radio button control:

JavaScript, JScript

function Test()
{
  // Select the Android device
  Mobile.SetCurrent("MyDevice");

  // Obtain the RadioButton object
  var p = Mobile.Device().Process("com.example.myapp");
  var l = p.RootLayout("").Layout("layoutTop").Layout("layout1");
  var Radio = l.RadioGroup("radiogroup1").RadioButton("radio1");
   
  // Touch RadioButton
  Radio.Touch();
}

Python

def Test():
  # Select the Android device
  Mobile.SetCurrent("MyDevice")

  # Obtain the RadioButton object
  p = Mobile.Device().Process("com.example.myapp")
  l = p.RootLayout("").Layout("layoutTop").Layout("layout1")
  Radio = l.RadioGroup("radiogroup1").RadioButton("radio1")
   
  # Touch RadioButton
  Radio.Touch()

VBScript

Sub Test()
  ' Select the Android device
  Mobile.SetCurrent("MyDevice")

  ' Obtain the RadioButton object
  Set p = Mobile.Device.Process("com.example.myapp")
  Set l = p.RootLayout("").Layout("layoutTop").Layout("layout1")
  Set Radio = l.RadioGroup("radiogroup1").RadioButton("radio1")

  ' Touch RadioButton
  Radio.Touch
End Sub

DelphiScript

procedure Test();
var
  p, l, Radio : OleVariant;
begin
  // Select the Android device
  Mobile.SetCurrent('MyDevice');

  // Obtain the RadioButton object
  p := Mobile.Device.Process('com.example.myapp');
  l := p.RootLayout('').Layout('layoutTop').Layout('layout1');
  Radio := l.RadioGroup('radiogroup1').RadioButton('radio1');
  
  // Touch RadioButton
  Radio.Touch;
end;

C++Script, C#Script

function Test()
{
  // Select the Android device
  Mobile["SetCurrent"]("MyDevice");

  // Obtain the RadioButton object
  var p = Mobile["Device"]["Process"]("com.example.myapp");
  var l = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layout1");
  var Radio = l["RadioGroup"]("radiogroup1")["RadioButton"]("radio1");
   
  // Touch RadioButton
  Radio["Touch"]();
}

Simulating Actions From Keyword Tests

This topic explains how to select the radio button control in scripts. You can use the described method in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.

See Also

Working With Android Radio Button Controls
Determining a Radio Button's State
Touch Action (Mobile Objects)
TouchButton Action (Mobile Controls)

Highlight search results