> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-en/action-guides/element/get-element-text.md).

# Get element text

This action helps the tool "read" and retrieve all the displayed text on an element (such as article content, title, price, or account name) and store it in a variable for your use.

* Purpose: Used when you need to scrape textual data from a website. You just need to specify the correct position (element), and the tool will automatically extract the displayed text from the interface for you.

#### Explanation of configuration parameters:

* XPath: The XPath identifier path of the element containing the text to be retrieved on the web page interface.
* Output variable: The variable name to store the text content after successful extraction.

#### Real-world example: Scraping the price of a product

Based on the store interface image you provided, you want to scrape the price of the Samsung Galaxy S6 phone for price comparison or to synchronize data to your system.

Looking at the highlighted HTML source code table on the right side of the image below:

> Structure of the tag containing the price: `<h5>$360</h5>`

To retrieve the text string of the price `$360`, you will configure the action as follows:

* Element XPath: Enter the exact XPath path that points directly to the tag containing the product's price, for example: `//div[@class='card h-100']//h5` (as shown in the XPath search box you successfully tested in the image).
* Output variable: Name the output variable `productPrice`.

Result: The system will find the corresponding `<h5>` tag of the product, extract the plain text located between the tags, and directly load the value `$360` into the variable `$productPrice`. In subsequent steps, you can call this variable to write to an Excel file or send it to the system data.

<figure><img src="/files/kqomosTslwfWRnYX9QCh" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/iAN95PrzeM7fL2ngma5M" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-en/action-guides/element/get-element-text.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
