Playwright · Junior · Question 68 of 75

Which assertion checks an element's attribute?

Show the answer

Correct answer: await expect(link).toHaveAttribute('href', '/docs')

Explanation

toHaveAttribute reads the DOM attribute with retries. toHaveJSProperty checks a JavaScript property instead.

Further reading

Problem with a question

Playwright · Junior · question 68

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