Testing · Junior · Question 45 of 78
How do you find the “Save” button?
- ✓Correct answer:
screen.getByRole("button", { name: "Save" }) - 2
screen.getByTestId("save") - 3
document.querySelector(".btn-save")
Explanation
name is the accessible name: the button's text, aria-label or aria-labelledby. Such a query also checks that the button is accessible.