class Playwright::Page

def get_by_text(text, exact: nil)

Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For example, locating by text `"Log in"` matches ``.

Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.

**Details**

```
page.get_by_text(re.compile("^hello$", re.IGNORECASE))
# Matches second


page.get_by_text(re.compile("Hello"))
# Matches both
s

page.get_by_text("Hello", exact=True)
# Matches second


page.get_by_text("Hello world")
# Matches first


page.get_by_text("world")
# Matches
```python sync

You can locate by text substring, exact string, or a regular expression:

```
Hello

Hello world

```html

Consider the following DOM structure:

**Usage**

See also [`method: Locator.filter`] that allows to match by another criteria, like an accessible role, and then filter by the text content.

Allows locating elements that contain given text.
def get_by_text(text, exact: nil)
  wrap_impl(@impl.get_by_text(unwrap_impl(text), exact: unwrap_impl(exact)))
end