# Extract Text from Screen using AI

Leverage the power of AI to extract specific pieces of information from the screen using natural language commands. This is particularly useful when the text you need is part of a larger block or not a distinct UI element.

<figure><img src="https://3741940050-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYlJodSwxTIBbHmZhKEX5%2Fuploads%2FeHb0wIpOfhN2kkerG7r6%2FScreenshot%202025-08-06%20at%2010.53.31%E2%80%AFAM.png?alt=media&#x26;token=a5eb973a-e847-4bff-8997-c809d2f3b12f" alt=""><figcaption></figcaption></figure>

**How to Extract Text with AI:**

1.  **Describe Your Goal:** In the **"Extract Text using AI"** section, you'll find a text box. Describe what information you want to extract from the current screen and what you'd like to name the variable that will store it.

    For example, to get the number of centuries from the article about Virat Kohli and save it to a variable named noOfCenturies, you would type:

    Extract the number of centuries by Virat Kohli to variable "noOfCenturies"
2. **Add the Step:** Click the **Create** button at the bottom right.

This will add a new AI-powered step to your test case.

**After Execution:**

Once the test step is executed, the AI will scan the screen, find the requested information, and populate the following fields:

* **Variable name:** The name of the variable where the text is stored (e.g., noOfCenturies).
* **Captured text:** The actual text that was extracted from the screen.

You can then use this variable in subsequent steps of your test, for example, to validate that the number is correct or to perform other actions.

## Crafting Your Prompt

Keep it simple:

* **Specify what to extract** (e.g., username, price, error message)
* **Name your variable** (e.g., currentUser, itemPrice, errorText)
* **Optional:** Ask for processing (e.g., `uppercase`, `numbers only`)

> **Format**: _Extract the_ **\[element]** _to variable_ **\[variableName]**_._

> **Example**: `Extract the price and convert to numbers only to variable itemPrice.`

***

#### 3. Real-World Examples

<table><thead><tr><th width="546.7265625">Your Prompt</th><th width="225.453125">What You Get</th></tr></thead><tbody><tr><td><code>Extract the username to variable currentUser.</code></td><td><strong>currentUser:</strong> <code>john.doe</code></td></tr><tr><td><code>Get the total amount to variable orderTotal.</code></td><td><strong>orderTotal:</strong> <code>$149.99</code></td></tr><tr><td><code>Extract the error message to variable errorText.</code></td><td><strong>errorText:</strong> <code>Invalid email</code></td></tr><tr><td><code>Extract the price and convert to numbers only to variable p.</code></td><td><strong>p:</strong> <code>29.99</code></td></tr><tr><td><code>Extract the welcome title to variable title in uppercase.</code></td><td><strong>title:</strong> <code>WELCOME BACK!</code></td></tr></tbody></table>

Each example shows exactly what the AI finds and how it assigns the value.

***

#### 4. Tips for Success

* **Be specific:** If there are multiple similar labels, mention context (e.g., profile section).
* **Ask processing properly:** Perform calculation (for ex. add all items.) or strip symbols in the same request.
