wState Property (Mobile Controls)

Applies to TestComplete 15.68, last modified on October 16, 2024
This property is available in legacy mobile tests that work with devices connected to the local computer. To learn how to simulate user actions in newer cloud-compatible mobile tests, see the Simulating user actions in tests section.

Description

Check box, toggle button and switch controls can be in the checked or unchecked state. Use the wState property to specify the current state of a control.

Declaration

TestObj.wState

Read-Write Property Integer
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section

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.

Property Value

The wState property can have one of the following values:

Constant Value Description
cbUnchecked 0 or False The control is unchecked.
cbChecked 1 or True The control is checked.

Example

The example below demonstrates how you can obtain and change the wState property of the check box:

JavaScript, JScript

function Test()
{
  var p, Checkbox

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

  // Obtain the CheckBox object
  p = Mobile.Device().Process("com.example.myapp");
  Checkbox = p.RootLayout("").Layout("layoutTop").Layout("layout1").CheckBox("check1");
  
  // Record the checkbox state to the log
  Log.Message(Checkbox.wState);
  
  // Change the chechbox state to "Checked"
  Checkbox.wState = cbChecked;
}

Python

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

  # Obtain the CheckBox object
  p = Mobile.Device().Process("com.example.myapp")
  Checkbox = p.RootLayout("").Layout("layoutTop").Layout("layout1").CheckBox("check1")
  
  # Record the checkbox state to the log
  Log.Message(Checkbox.wState)
  
  # Change the chechbox state to "Checked"
  Checkbox.wState = cbChecked

VBScript

Sub Test
  Dim p, Checkbox

  ' Select the Android device
  Mobile.SetCurrent("MyDevice")
  
  ' Obtain the CheckBox object
  Set p = Mobile.Device.Process("com.example.myapp")
  Set Checkbox = p.RootLayout("").Layout("layoutTop").Layout("layout1").CheckBox("check1")
  
  ' Record the checkbox state to the log
  Log.Message(Checkbox.wState)
  
  ' Change the chechbox state to "Checked"
  Checkbox.wState = cbChecked
End Sub

DelphiScript

procedure Test;
  var p, Checkbox;
begin
  // Select the Android device
  Mobile.SetCurrent('MyDevice');

  // Obtain the CheckBox object
  p := Mobile.Device.Process('com.example.myapp');
  Checkbox := p.RootLayout('').Layout('layoutTop').Layout('layout1').CheckBox('check1');
  
  // Record the checkbox state to the log
  Log.Message(Checkbox.wState);
  
  // Change the chechbox state to 'Checked'
  Checkbox.wState := cbChecked;
end;

C++Script, C#Script

function Test()
{
  var p, Checkbox

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

  // Obtain the CheckBox object
  p = Mobile["Device"].Process("com.example.myapp");
  Checkbox = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layout1")["CheckBox"]("check1");
  
  // Record the checkbox state to the log
  Log["Message"](Checkbox["wState"]);
  
  // Change the chechbox state to "Checked"
  Checkbox["wState"] = cbChecked;
}

See Also

Testing Android Applications (Legacy)
Testing iOS Applications (Legacy)
Determining a Check Box's State
Determining a Switch's State
Determining a Toggle Button's State
Determining a Switch's State

Highlight search results