For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/react/testing-library/接口/ByRoleOptions.md.
Lynx
  • 简体中文
    • English
  • 接口: ByRoleOptions

    属性

    busy?

    optional busy?: boolean

    为 true 时,查询结果只包含在无障碍树中被标记为 busy 的元素,即 aria-busy="true"


    checked?

    optional checked?: boolean

    为 true 时,查询结果只包含在无障碍树中被标记为 checked 的元素,即 aria-checked="true"


    current?

    optional current?: string | boolean

    按元素的 aria-current 状态进行过滤。true 和 false 分别匹配 aria-current="true" 和 aria-current="false"(以及缺少 aria-current 属性的情况)。


    description?

    optional description?: string | RegExp | ((accessibleDescription: string, element: Element) => boolean)

    仅考虑具有指定无障碍描述(accessible description)的元素。


    expanded?

    optional expanded?: boolean

    为 true 时,查询结果只包含在无障碍树中被标记为 expanded 的元素,即 aria-expanded="true"


    hidden?

    optional hidden?: boolean

    为 true 时,查询结果会包含通常被排除在无障碍树之外的元素。无论如何都会包含 role="none" 或 role="presentation" 的元素。


    level?

    optional level?: number

    包含 "heading" 角色且级别匹配的元素,可以是语义化的 HTML 标题元素 <h1>-<h6>,也可以是匹配 aria-level 属性的元素。


    name?

    optional name?: string | RegExp | ((accessibleName: string, element: Element) => boolean)

    仅考虑具有指定无障碍名称(accessible name)的元素。


    pressed?

    optional pressed?: boolean

    为 true 时,查询结果只包含在无障碍树中被标记为 pressed 的元素,即 aria-pressed="true"


    queryFallbacks?

    optional queryFallbacks?: boolean

    包含 role 属性中使用的每一个 role。 例如 *ByRole('progressbar', {queryFallbacks: true}) will find <div role="meter progressbar">。


    selected?

    optional selected?: boolean

    为 true 时,查询结果只包含在无障碍树中被标记为 selected 的元素,即 aria-selected="true"


    suggest?

    optional suggest?: boolean

    为特定查询禁用建议


    value?

    optional value?: object

    max?

    optional max?: number

    min?

    optional min?: number

    now?

    optional now?: number

    text?

    optional text?: Matcher

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。