Playwright · Junior · Question 22 of 75
How do you pick the second row of a list deliberately?
- 1
page.getByRole('listitem').nth(1) - 2
page.getByRole('listitem').second() - 3
page.getByRole('listitem')[1]
Show the answer
Correct answer: page.getByRole('listitem').nth(1)
Explanation
nth() is zero-based, with first() and last() as shortcuts. Prefer filtering by content when possible, since order can change.