Use case
Tri-state checkboxes are standard UI in tree views and "select all" table headers: the parent checkbox is neither checked nor unchecked but indeterminate (element.indeterminate = true). Playwright supports asserting this via toBeChecked({ indeterminate: true }).
Get Checkbox State today only reads the checked property, so an indeterminate checkbox simply reports whatever checked happens to be — the mixed state cannot be asserted. The workaround, Get Property selector indeterminate, works but is undiscoverable: nothing in the checkbox keyword documentation hints at it, and users reasonably expect the checkbox keyword to cover checkbox states.
A small named-only argument on the existing keyword closes this parity gap where users will actually look for it.
Proposed keyword / arguments
Get Checkbox State selector assertion_operator=None assertion_expected=Unchecked message=None state_type=checked
| Argument |
Description |
state_type |
New named-only enum: checked (default, current behavior — reads element.checked) or indeterminate (reads element.indeterminate). |
With state_type=indeterminate the keyword returns True when the checkbox is in the mixed state, False otherwise; assertion semantics are unchanged (boolean ==/!=).
*** Test Cases ***
Select All Shows Mixed State
Check Checkbox css=tbody tr:first-child input[type=checkbox]
Get Checkbox State id=select-all == checked state_type=indeterminate
Parent Resolves After Selecting All Rows
Check Checkbox css=tbody tr:nth-child(2) input[type=checkbox]
Get Checkbox State id=select-all == unchecked state_type=indeterminate
Get Checkbox State id=select-all == checked
Playwright API
Implementation notes
- No proto change expected: the wrapper already reads boolean element properties via the generic
GetBoolProperty RPC (Get Checkbox State passes property="checked" today); the new argument just switches the property name to indeterminate.
Browser/keywords/getters.py: add the named-only state_type argument with a CheckboxStateType enum; adjust log/error messages to name the asserted state.
- Docs update + atest with a tri-state checkbox in the test app.
Backwards compatibility
Additive named-only argument whose default (checked) preserves current behavior exactly; existing suites are unaffected.
Use case
Tri-state checkboxes are standard UI in tree views and "select all" table headers: the parent checkbox is neither checked nor unchecked but indeterminate (
element.indeterminate = true). Playwright supports asserting this viatoBeChecked({ indeterminate: true }).Get Checkbox Statetoday only reads thecheckedproperty, so an indeterminate checkbox simply reports whatevercheckedhappens to be — the mixed state cannot be asserted. The workaround,Get Property selector indeterminate, works but is undiscoverable: nothing in the checkbox keyword documentation hints at it, and users reasonably expect the checkbox keyword to cover checkbox states.A small named-only argument on the existing keyword closes this parity gap where users will actually look for it.
Proposed keyword / arguments
state_typechecked(default, current behavior — readselement.checked) orindeterminate(readselement.indeterminate).With
state_type=indeterminatethe keyword returnsTruewhen the checkbox is in the mixed state,Falseotherwise; assertion semantics are unchanged (boolean==/!=).Playwright API
indeterminate: trueoption (v1.50).Implementation notes
GetBoolPropertyRPC (Get Checkbox Statepassesproperty="checked"today); the new argument just switches the property name toindeterminate.Browser/keywords/getters.py: add the named-onlystate_typeargument with aCheckboxStateTypeenum; adjust log/error messages to name the asserted state.Backwards compatibility
Additive named-only argument whose default (
checked) preserves current behavior exactly; existing suites are unaffected.