Playwright · Junior · Question 33 of 75

What does toHaveText check?

await expect(page.getByRole("status")).toHaveText("Saved");
Show the answer

Correct answer: The element's text matches, retrying until timeout

Explanation

Web-first assertions keep retrying until the condition holds or the expect timeout runs out. toContainText checks a substring instead of the full text.

Further reading

Problem with a question

Playwright · Junior · question 33

Test yourself

Take the Playwright · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz