Skip to content

Add Get Accessible Property keyword to assert accessible name, description, role and error message #5123

Description

@Snooz82

Use case

Accessibility testing is a mainstream requirement now, but the library has no way to check what assistive technologies actually see for a single element. Playwright ships four dedicated assertions for this — accessible name, accessible description, ARIA role and accessible error message — and none of them has a getter equivalent in Browser library today.

The current situation for users:

  • Get Aria Snapshot exposes role/name of a whole subtree in YAML, which is awkward and brittle when you only want to check one element's computed accessible name.
  • Computed accessible description and accessible error message (from aria-describedby/aria-errormessage) are not reachable at all — the accname algorithm (label elements, aria-labelledby chains, alt text, etc.) is far too complex to reimplement in a hand-written Evaluate JavaScript snippet.

A single assertion-engine getter with a property selector covers all four checks with auto-retry (Set Retry Assertions For), following the library's established getter idiom.

Proposed keyword / arguments

Get Accessible Property    selector    property=name    assertion_operator=None    assertion_expected=None    message=None
Argument Description
selector Element selector, strict mode applies.
property Enum: name (default), description, role, errormessage.
assertion_operator / assertion_expected / message Standard assertion-engine arguments with auto-retry.

Returns the computed value as a string (empty string when the property is not set).

*** Test Cases ***
Accessible Properties
    Get Accessible Property    id=submit    name    ==    Submit form
    Get Accessible Property    id=avatar    description    contains    profile picture
    Get Accessible Property    css=.primary-action    role    ==    button
    Fill Text    id=email    not-an-email
    Blur    id=email
    Get Accessible Property    id=email    errormessage    ==    Please enter a valid e-mail address
    ${name} =    Get Accessible Property    id=logo    name

Playwright API

Covers the getter side of four LocatorAssertions:

The wrapper can reuse the same accname computation Playwright's expect uses (injected aria utils in playwright-core), so results match Playwright assertions exactly.

Implementation notes

  • protobuf/playwright.proto: new request message carrying selector + property enum (or reuse an existing selector/property request shape) and a string-response RPC.
  • node/playwright-wrapper: resolve the locator, compute the requested accessible property via Playwright's injected aria utilities.
  • Browser/keywords/getters.py: new keyword with @with_assertion_polling, tags Getter, Assertion, PageContent; new AccessibleProperty enum in the types module.
  • Docs + inv build stub regen, atest cases against the test app (labelled inputs, aria-describedby, aria-errormessage, implicit/explicit roles).

Backwards compatibility

Purely additive: a new keyword, no changes to any existing keyword or return value.

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