class Playwright::Locator
def count
count = page.get_by_role("listitem").count()
```python sync
**Usage**
**NOTE**: If you need to assert the number of elements on the page, prefer [`method: LocatorAssertions.toHaveCount`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
Returns the number of elements matching the locator.
def count wrap_impl(@impl.count) end