Extract Text from Screen

You can easily extract text from any UI element on the device screen and store it in a variable for later use in your test.

Test Steps:

  1. Select the Element: While in recording or inspection mode, click on the desired element on the device screen. A green box will highlight the selected element.

  2. Choose the Extraction Action: A context menu will appear with several interaction options. Select "Extract text to a variable".

A new step will be added to your test flow, which will save the text from the selected element (in this case, "Constans II (son of Constantine III)") into a variable when the test is run.

Using Regex for Text Extraction

You can also extract specific text patterns from strings

Need help creating a regex pattern? Click on Use AI to write regex to ask Finalrun AI to generate one for you based on your requirements, then use it directly in our platform.

Examples

Example 1: Extracting amount

Pattern: ₹\s*([0-9]+)
Input: ₹100
Output: 100

Example 2: Extracting Phone Numbers

Pattern: (\d{3}[-.\s]?\d{3}[-.\s]?\d{4})
Input: Call us at 555-123-4567 or 555.987.6543 for more information.
Output: 555-123-4567

Example 3: Extracting URLs

Pattern: (https?://[^\s]+)
Input: Visit our website at https://example.com or http://demo.example.org for more details.
Output: https://example.com

Example 4: Named Capture Groups

Pattern: (?<username>[a-zA-Z0-9_]+):(?<message>.+)
Input: john_doe: Hello world! alice_smith: How are you?
Output: username: john_doe, message: Hello world!

Example 5: Extracting Dates

Pattern: (\d{1,2}/\d{1,2}/\d{2,4})
Input: The meeting is scheduled for 10/15/2023 and the deadline is 12/31/2023.
Output: 10/15/2023

Example 6: Extracting Product Codes

Pattern: ([A-Z]{2}-\d{4})
Input: Please reorder products AB-1234 and CD-5678 before next month.
Output: AB-1234

Example 7: Extracting Hashtags

Pattern: (#\w+)
Input: Check out our new product launch #NewRelease #Innovation #Tech
Output: #NewRelease

Example 8: Extracting Time

Pattern: (\d{1,2}:\d{2}(?::\d{2})?\s*(?:AM|PM)?)
Input: The meeting starts at 9:30 AM and ends at 11:45 AM.
Output: 9:30 AM

Example 9: Extracting Names

Pattern: (Mr\.|Ms\.|Mrs\.|Dr\.)\s([A-Z][a-z]+)
Input: Dr. Smith and Mrs. Johnson will attend the conference.
Output: Dr. Smith

Example 10: Extracting IP Addresses

Pattern: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
Input: The server IP addresses are 192.168.1.1 and 10.0.0.1
Output: 192.168.1.1

Features Not Covered

Our platform focuses on text extraction and does not support:

  • Lookahead/lookbehind assertions

  • Atomic grouping

  • Conditional patterns

  • Advanced backtracking controls

Last updated