Skip to content

Add state_type=checked|indeterminate argument to Get Checkbox State for tri-state checkboxes #5121

Description

@Snooz82

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions