# class: Locator
* since: v1.14
Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent
a way to find element(s) on the page at any moment. A locator can be created with the [`method: Page.locator`] method.
[Learn more about locators](../locators.md).
## async method: Locator.all
* since: v1.29
- returns: <[Array]<[Locator]>>
When the locator points to a list of elements, this returns an array of locators, pointing to their respective elements.
:::note
[`method: Locator.all`] does not wait for elements to match the locator, and instead immediately returns whatever is present in the page.
When the list of elements changes dynamically, [`method: Locator.all`] will produce unpredictable and flaky results.
When the list of elements is stable, but loaded dynamically, wait for the full list to finish loading before calling [`method: Locator.all`].
:::
**Usage**
```js
for (const li of await page.getByRole('listitem').all())
await li.click();
```
```python async
for li in await page.get_by_role('listitem').all():
await li.click();
```
```python sync
for li in page.get_by_role('listitem').all():
li.click();
```
```java
for (Locator li : page.getByRole('listitem').all())
li.click();
```
```csharp
foreach (var li in await page.GetByRole("listitem").AllAsync())
await li.ClickAsync();
```
## async method: Locator.allInnerTexts
* since: v1.14
- returns: <[Array]<[string]>>
Returns an array of `node.innerText` values for all matching nodes.
**Usage**
```js
const texts = await page.getByRole('link').allInnerTexts();
```
```python async
texts = await page.get_by_role("link").all_inner_texts()
```
```python sync
texts = page.get_by_role("link").all_inner_texts()
```
```java
String[] texts = page.getByRole(AriaRole.LINK).allInnerTexts();
```
```csharp
var texts = await page.GetByRole(AriaRole.Link).AllInnerTextsAsync();
```
## async method: Locator.allTextContents
* since: v1.14
- returns: <[Array]<[string]>>
Returns an array of `node.textContent` values for all matching nodes.
**Usage**
```js
const texts = await page.getByRole('link').allTextContents();
```
```python async
texts = await page.get_by_role("link").all_text_contents()
```
```python sync
texts = page.get_by_role("link").all_text_contents()
```
```java
String[] texts = page.getByRole(AriaRole.LINK).allTextContents();
```
```csharp
var texts = await page.GetByRole(AriaRole.Link).AllTextContentsAsync();
```
## method: Locator.and
* since: v1.34
* langs:
- alias-python: and_
- returns: <[Locator]>
Creates a locator that matches both this locator and the argument locator.
**Usage**
The following example finds a button with a specific title.
```js
const button = page.getByRole('button').and(page.getByTitle('Subscribe'));
```
```java
Locator button = page.getByRole(AriaRole.BUTTON).and(page.getByTitle("Subscribe"));
```
```python async
button = page.get_by_role("button").and_(page.getByTitle("Subscribe"))
```
```python sync
button = page.get_by_role("button").and_(page.getByTitle("Subscribe"))
```
```csharp
var button = page.GetByRole(AriaRole.Button).And(page.GetByTitle("Subscribe"));
```
### param: Locator.and.locator
* since: v1.34
- `locator` <[Locator]>
Additional locator to match.
## async method: Locator.blur
* since: v1.28
Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur) on the element.
### option: Locator.blur.timeout = %%-input-timeout-%%
* since: v1.28
### option: Locator.blur.timeout = %%-input-timeout-js-%%
* since: v1.28
## async method: Locator.boundingBox
* since: v1.14
- returns: <[null]|[Object]>
- `x` <[float]> the x coordinate of the element in pixels.
- `y` <[float]> the y coordinate of the element in pixels.
- `width` <[float]> the width of the element in pixels.
- `height` <[float]> the height of the element in pixels.
This method returns the bounding box of the element matching the locator, or `null` if the element is not visible. The bounding box is
calculated relative to the main frame viewport - which is usually the same as the browser window.
**Details**
Scrolling affects the returned bounding box, similarly to
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
means `x` and/or `y` may be negative.
Elements from child frames return the bounding box relative to the main frame, unlike the
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
snippet should click the center of the element.
**Usage**
```js
const box = await page.getByRole('button').boundingBox();
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
```
```java
BoundingBox box = page.getByRole(AriaRole.BUTTON).boundingBox();
page.mouse().click(box.x + box.width / 2, box.y + box.height / 2);
```
```python async
box = await page.get_by_role("button").bounding_box()
await page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
```
```python sync
box = page.get_by_role("button").bounding_box()
page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
```
```csharp
var box = await page.GetByRole(AriaRole.Button).BoundingBoxAsync();
await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2);
```
### option: Locator.boundingBox.timeout = %%-input-timeout-%%
* since: v1.14
### option: Locator.boundingBox.timeout = %%-input-timeout-js-%%
* since: v1.14
## async method: Locator.check
* since: v1.14
Ensure that checkbox or radio element is checked.
**Details**
Performs the following steps:
1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
checked, this method returns immediately.
1. Wait for [actionability](../actionability.md) checks on the element, unless [`option: force`] option is set.
1. Scroll the element into view if needed.
1. Use [`property: Page.mouse`] to click in the center of the element.
1. Wait for initiated navigations to either succeed or fail, unless [`option: noWaitAfter`] option is set.
1. Ensure that the element is now checked. If not, this method throws.
If the element is detached from the DOM at any moment during the action, this method throws.
When all steps combined have not finished during the specified [`option: timeout`], this method throws a
[TimeoutError]. Passing zero timeout disables this.
**Usage**
```js
await page.getByRole('checkbox').check();
```
```java
page.getByRole(AriaRole.CHECKBOX).check();
```
```python async
await page.get_by_role("checkbox").check()
```
```python sync
page.get_by_role("checkbox").check()
```
```csharp
await page.GetByRole(AriaRole.Checkbox).CheckAsync();
```
### option: Locator.check.position = %%-input-position-%%
* since: v1.14
### option: Locator.check.force = %%-input-force-%%
* since: v1.14
### option: Locator.check.noWaitAfter = %%-input-no-wait-after-%%
* since: v1.14
### option: Locator.check.timeout = %%-input-timeout-%%
* since: v1.14
### option: Locator.check.timeout = %%-input-timeout-js-%%
* since: v1.14
### option: Locator.check.trial = %%-input-trial-%%
* since: v1.14
## async method: Locator.clear
* since: v1.28
Clear the input field.
**Details**
This method waits for [actionability](../actionability.md) checks, focuses the element, clears it and triggers an `input` event after clearing.
If the target element is not an ``, `