Skip to content

Unable to *byRole the <input type="password" /> element #1382

Description

@sausir1
  • @testing-library/dom version: "9.3.4"
  • Testing Framework and version:
    "@testing-library/jest-dom": "^6.9.1"
    "@testing-library/vue": "^8.1.0"
  • DOM Environment:
    "happy-dom": "^20.10.6"
    but also reproducible on "jsdom": "^24.1.3"

What you did:

I was trying to write a wrapper for picking up form elements, and noticed a quite strange bug - no accessible role is attached to the <input type="password" /> HTML element. When logging the roles, the element is totally omitted.

What happened:

Wrote up a small reproduction case, please check it out. It should log roles for both inputs in the provided code example, but only the <input type="text" /> is printed to the console:

textbox:

Name "":
<input
  data-attr="hello"
  type="textbox"
/>

Reproduction:

reproduction: https://stackblitz.com/edit/dtl-template-qjgkn4zv?file=src%2Fmain.test.ts

when in repository, launch tests

Problem description:

It is unable to get <input type="password" /> elements by their role. Tried textbox and password text roles, but they don't work (when listing roles, it is marked as a generic)

Suggested solution:

When inspected the Accesibility tree on Firefox browser, the password field has a role of password text, which could be used to attach the correct role here too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions