Skip to content

getByText doesn't find nodes that are <input type="submit" value="XXX"> #248

Closed
testing-library/dom-testing-library
#185
@julienw

Description

@julienw

I use a code that contains an submit button like this:

        <input
          className="compareHome-submit-button"
          type="submit"
          value="Retrieve profiles"
        />

With react-testing-library I want to get it using for example getByText('Retrieve profiles'), which I expect to work because the text 'Retrieve profiles' is actually seen by users.

But this doesn't work and fails with this error:

    Unable to find an element with the text: Retrieve profiles. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

Is this error expected in this case? I don't find an easy way to get to the submit button and have to use a matcher function instead...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions