class Playwright::Locator

Learn more about locators](../locators.md).
a way to find element(s) on the page at any moment. A locator can be created with the [‘method: Page.locator`

method.
Locators are the central piece of Playwright’s auto-waiting and retry-ability. In a nutshell, locators represent

def all

```
li.click();
for li in page.get_by_role('listitem').all():
```python sync

**Usage**

When the list of elements is stable, but loaded dynamically, wait for the full list to finish loading before calling [`method: Locator.all`].

When the list of elements changes dynamically, [`method: Locator.all`] will produce unpredictable and flaky results.

**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 locator points to a list of elements, this returns an array of locators, pointing to their respective elements.
def all
  wrap_impl(@impl.all)
end

def all_inner_texts

```
texts = page.get_by_role("link").all_inner_texts()
```python sync

**Usage**

**NOTE**: If you need to assert text on the page, prefer [`method: LocatorAssertions.toHaveText`] with `useInnerText` option to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.

Returns an array of `node.innerText` values for all matching nodes.
def all_inner_texts
  wrap_impl(@impl.all_inner_texts)
end

def all_text_contents

```
texts = page.get_by_role("link").all_text_contents()
```python sync

**Usage**

**NOTE**: If you need to assert text on the page, prefer [`method: LocatorAssertions.toHaveText`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.

Returns an array of `node.textContent` values for all matching nodes.
def all_text_contents
  wrap_impl(@impl.all_text_contents)
end

def and(locator)

```
button = page.get_by_role("button").and_(page.getByTitle("Subscribe"))
```python sync

The following example finds a button with a specific title.

**Usage**

Creates a locator that matches both this locator and the argument locator.
def and(locator)
  wrap_impl(@impl.and(unwrap_impl(locator)))
end

def blur(timeout: nil)

Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur) on the element.
def blur(timeout: nil)
  wrap_impl(@impl.blur(timeout: unwrap_impl(timeout)))
end

def bounding_box(timeout: nil)

```
page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
box = page.get_by_role("button").bounding_box()
```python sync

**Usage**

snippet should click the center of the element.
Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following

[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
Elements from child frames return the bounding box relative to the main frame, unlike the

means `x` and/or `y` may be negative.
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
Scrolling affects the returned bounding box, similarly to

**Details**

calculated relative to the main frame viewport - which is usually the same as the browser window.
This method returns the bounding box of the element matching the locator, or `null` if the element is not visible. The bounding box is
def bounding_box(timeout: nil)
  wrap_impl(@impl.bounding_box(timeout: unwrap_impl(timeout)))
end

def check(

```
page.get_by_role("checkbox").check()
```python sync

**Usage**

`TimeoutError`. Passing zero timeout disables this.
When all steps combined have not finished during the specified `timeout`, this method throws a

If the element is detached from the DOM at any moment during the action, this method throws.

1. Ensure that the element is now checked. If not, this method throws.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
1. Use [`property: Page.mouse`] to click in the center of the element.
1. Scroll the element into view if needed.
1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
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.
Performs the following steps:

**Details**

Ensure that checkbox or radio element is checked.
def check(
      force: nil,
      noWaitAfter: nil,
      position: nil,
      timeout: nil,
      trial: nil)
  wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
end

def checked?(timeout: nil)

```
checked = page.get_by_role("checkbox").is_checked()
```python sync

**Usage**

**NOTE**: If you need to assert that checkbox is checked, prefer [`method: LocatorAssertions.toBeChecked`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.

Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
def checked?(timeout: nil)
  wrap_impl(@impl.checked?(timeout: unwrap_impl(timeout)))
end

def clear(force: nil, noWaitAfter: nil, timeout: nil)

```
page.get_by_role("textbox").clear()
```python sync

**Usage**

If the target element is not an ``, `