Playwright · Junior · Question 70 of 75
Which assertion checks the page <title>?
- 1
await expect(page.title).toBe('Dashboard') - 2
await expect(page).toHaveTitle(/Dashboard/) - 3
await expect(page.locator('title')).toBeVisible()
Show the answer
Correct answer: await expect(page).toHaveTitle(/Dashboard/)
Explanation
toHaveTitle retries until the document title matches a string or regular expression.