Represents the checkbox control (<input type="checkbox">). Default search is performed by the label.

Inherited from EditableField.

Syntax

[ControlDefinition("input[@type='checkbox']", ComponentTypeName = "checkbox", IgnoreNameEndings = "Checkbox,CheckBox,Option")]
[ControlFinding(FindTermBy.Label)]
public class CheckBox<TOwner> : EditableField<bool, TOwner>, ICheckable<TOwner>
    where TOwner : PageObject<TOwner>

Properties

public DataProvider<bool, TOwner>

IsChecked { get; }

Gets the DataProvider<bool, TOwner> instance of the checked state value.

Methods

public TOwner

Check()

Checks the control. Also executes TriggerEvents.BeforeSet and TriggerEvents.AfterSet triggers.

public TOwner

Uncheck()

Unchecks the control. Also executes TriggerEvents.BeforeSet and TriggerEvents.AfterSet triggers.

Example

<label class="checkbox-inline">
  <input type="checkbox" value="option1">Option 1
</label>
<label class="checkbox-inline">
  <input type="checkbox" value="option2" checked>Option 2
</label>
using Atata;

namespace SampleApp
{
    using _ = SamplePage;

    public class SamplePage : Page<_>
    {
        [FindByLabel]
        public CheckBox<_> Option1 { get; private set; }

        [FindByLabel]
        public CheckBox<_> Option2 { get; private set; }
    }
}
Go.To<SamplePage>().
    Option1.Check().
    Option1.Should.BeChecked().
    Option2.Uncheck().
    Option2.Should.Not.BeChecked();