Playwright · Method
locator.count
locator.count() returns the number of elements matching a locator. Use expect(locator).to_have_count() for count assertions to reduce flakiness.
Last updated
- Since
- v1.14
Syntax
locator.count()In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
locatorexpect(locator).toHaveCount()get_by_role