I have multiple buttons on my page:
<div>
<h1>Home</h1>
<button>Action 1</button>
<button>Action 2</button>
</div>
How can I select the "Action 2" button by its text, so that I can click on it? I know that there may be other ways to select that button, but I am specifically looking for the best way to select an element by its text.
One way I have found is shown below. Is there a better way?
const action2Button = wrapper.find('button[children="Action 2"]');
expect(action2Button).toHaveLength(1);
action2Button.simulate('click');