i want to get the div element within parent element with some test-id
what i am trying to do?
I have a parent div with test-id "parent-2" and it has a div element within it that has text Remove.
i want to retreive this Remove div element. also there is multiple Remove div elements. something like below
<div data-test-id="parent-1">
<div>Remove</div>
</div>
<div data-test-id="parent-2">
<div>Remove</div>
</div>
<div data-test-id="parent-3">
<div>Remove</div>
</div>
So in the above html code i want to click Remove div from div with parent test-id = "parent-2"
I have tried to do like below
utils.fireEvent.click(getByText('Remove'));
this throws error found multiple instances of Remove.
I tried also this utils.fireEvent.click(getByTestId('parent-2').children[0];
this works. but this accesses the first child of the parent. however wanted to be more specific with the query.
So how can i fix this such that i can click Remove div belong to div of test-id "parent-2"
thanks.