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

未关闭
#5,121 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
78/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
冷清
技术栈
playwright, python

调研方向

从 Browser/keywords/getters.py 开始,阅读现有的 Get Checkbox State 实现及其对 GetBoolProperty 的使用。添加 state_type 的 named-only 处理,然后在测试应用中使用 tri-state checkbox,更新 checkbox 文档和 atest。完成的标准是 checked 仍然是默认值,并且测试覆盖 indeterminate 断言。

由索引模型根据 Issue 内容生成。

描述

enhancement

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.

主要语言
Python
星标
662
派生
149
平均合并
6 小时 9 分钟
30 天内合并 PR
119

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MarketSquare/robotframework-browser 的其他 Issue

查看 MarketSquare/robotframework-browser 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。