Applies to TestComplete 14.30, last modified on November 21, 2019

Check box controls are used to select options. You may need to determine the state of the current check box if, for example, you need to make a choice depending on the option that is set by the current check box.

While testing check box 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.

To determine the state of a check box, you can use the wState property. This property belongs to the Win32CheckBox object and contains constants that describe the current state of the check box control.

The following code snippet determines the state of CheckBox1 and selects different sets of options according to this state:

JavaScript, JScript

  ...
  if (CheckBox1.wState == cbChecked)
  {
    CheckBox2.wState = cbChecked;
    CheckBox3.wState = cbUnchecked;
  }
  else 
  {
    CheckBox2.wState = cbUnchecked;
    CheckBox3.wState = cbChecked;
  }
  ...

Python

... 
if (CheckBox1.wState == cbChecked):
  CheckBox2.wState = cbChecked
  CheckBox3.wState = cbUnchecked
else:
  CheckBox2.wState = cbUnchecked
  CheckBox3.wState = cbChecked
...

VBScript

  ...
  If CheckBox1.wState = cbChecked Then 
    CheckBox2.wState = cbChecked
    CheckBox3.wState = cbUnchecked
  Else
    CheckBox2.wState = cbUnchecked
    CheckBox3.wState = cbChecked
  End If
  ...

DelphiScript

  ...
  if CheckBox1.wState = cbChecked then
    begin
      CheckBox2.wState := cbChecked;
      CheckBox3.wState := cbUnchecked;
    end
  else
    begin
      CheckBox2.wState := cbUnchecked;
      CheckBox3.wState := cbChecked;
    end;
  ...

C++Script, C#Script

  ...
  if (CheckBox1.wState == cbChecked)
  {
     CheckBox2["wState"] = cbChecked;
     CheckBox3["wState"] = cbUnchecked;
  }
  else 
  {
    CheckBox2["wState"] = cbUnchecked;
    CheckBox3["wState"] = cbChecked;
  }
  ...

Note: Typically, a check box has two states: checked and unchecked. In some cases, a check box can be determined as a three-state control. In this case, a check box can be checked, unchecked or it can be in the indeterminate state. If your application is Open, you can explore the control’s internal properties and determine whether a check box supports the third state (for more information on how to do this, see the About Open Applications topic).

See Also

Working With Check Box Controls
wState Property (CheckBox and ToggleButton Controls)

Highlight search results