# contains

## Syntax

```python
py.contains(text: str) -> Element
py.contains(text: str, timeout: int) -> Element

---or---

Element.contains(text: str) -> Element
Element.contains(timeout: int) -> Element
```

## Usage

{% code title="correct usage" %}

```python
# Yield Element in .nav containing "About"
py.get(".nav").contains("About")

---or---

# Yield first Element in document containing 'Hello'
py.contains("Hello")

---or--- # store in a variable

element = py.contains("About")

---or--- # chain an Element command

py.contains("About").click()

---or--- # control the timeout in any of the above usages

py.contains("Deck Builder", timeout=5).click()
```

{% endcode %}

{% code title="incorrect usage" %}

```python
# Errors, 'title' does not yield Element
py.title().contains("QAP")

---or---

# Errors, 'get_cookies' does not yield Element
py.get_cookies().contains("Cooke Monster")
```

{% endcode %}

## Arguments

* `text (str)` - The text to look for
* `timeout=None (int)` - The number of seconds for this command to succeed.
  * <mark style="color:purple;">`timeout=None`</mark> will use the default <mark style="color:orange;">**wait\_time**</mark> in [pylenium.json](/configuration/pylenium-json.md)
  * <mark style="color:purple;">`timeout=0`</mark> will poll the DOM immediately with no wait
  * Any value greater than zero will override the default **wait\_time**

{% hint style="info" %}
It does not need to be an *exact* match
{% endhint %}

## Yields

* <mark style="color:orange;">**Element**</mark> - The first element that is found, even if multiple elements match the query


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pylenium.io/driver-commands/find-elements/contains.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
