Working with Text in Eggplant Functional
When you need to find text, remember that you can capture an image of the text and let your script perform an image search. This works best in situations where the text is static and unchanging, such as button text. However, for scenarios where the text is dynamic or the text value to be searched isn't known ahead of time, Eggplant Functional (EPF) provides on an optical character recognition (OCR) engine to search the screen for the text string on the system under test (SUT).
There are multiple ways of finding text on the SUT:
When to Use Images vs. OCR to Find Text
While you can use OCR almost any time you need to search for text on the SUT, it should be treated as a secondary option to captured images. Take a moment to evaluate the situation to see if using a captured image is feasible or if you need to use OCR.
In situations that fit the descriptions below, try using a captured image before turning to OCR:
- The text is not dynamic.
- You know what text you are looking for ahead of time (it is not being pulled in from an external source during the script run).
- You do not need to read the text off of the SUT using
ReadText
, or the text can be instead copied using theRemoteClipboard
function and returned to the script that way. - Your test is against a single platform or system (not cross-platform or cross-browser).
- The text you are working with is set to a very small font size, or an abnormally large size.
OCR is well-suited to the following situations:
- You do not know the text you are looking for ahead of time, but the script will have access to that information by the time the search is conducted.
- The font, size, or color of the text can vary.
- Your testing includes a variety of browsers, and different browsers can render fonts differently.
- You need to read a text value from the SUT and bring that information back into your script for further testing or to record in an external data file.