MarketSquare / MarketSquare/robotframework-browser

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

Open
#5,121 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
655
Forks
147
Avg merge
5h 27m
Merged PRs (30d)
59

Description

## 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 `==`/`!=`).

```robotframework
*** 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

- [expect(locator).toBeChecked](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-checked) with the `indeterminate: true` option (v1.50).

## 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Browser/keywords/getters.py by reading the existing Get Checkbox State implementation and its GetBoolProperty usage. Add the named-only state_type handling, then update the checkbox documentation and the atest using a tri-state checkbox in the test app. Done means checked remains the default and indeterminate assertions are covered by the tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
testing-qa, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.