1. 9
    Get Elements With a Matching Display Value Using the byDisplayValue Query
    35s

Get Elements With a Matching Display Value Using the byDisplayValue Query

Daniel Afonso
InstructorDaniel Afonso
Share this video with your friends

Social Share Links

Send Tweet

Navigating a form with a bunch of elements with filled-in values can be a way to refer to certain elements.

In this lesson, we will look at another one of the queries that are part of the queries accessible to everyone's family and helpful when querying for filled-in form values the byDisplayValue query.

Instructor: [0:00] When you have a page with filled-in values, you might want to query for them. In this scenario, the byDisplayValue is the query that belongs to the queries accessible to everyone's family. That should help you.

[0:10] Looking at our component, we can see that we have an input with a defaultValue of 9001. This means that when this element renders, it will have a value of 9001. We can use this value to query for this element.

[0:20] Let's destructure the getByDisplayValue query from render. Then, let's call it and pass the value which our input should have, which in this scenario was 9001. Once we have our input, let's assert it is in the document and run our test. You should now see that our test has passed.