Playwright · Method
locator.first
locator.first returns a locator for the first element matched by another locator. It is useful when one element must be chosen from several matches, but a unique locator is usually safer.
Last updated
- Since
- v1.14
Syntax
locator.first()In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
locator.lastlocator.nthlocator.filterpage.getByRole