I have a scenario where I have to read text on the image and only text at a time in eggplant. Could anyone please help me with it?
1 Answers
Update: If the image you are trying to read with OCR is not on the System-Under-Test, you can use the Connect() command to open a "screenshot connection" using the type: "screenshot" parameter:
connect "/Users/bob/Documents/EggplantSuites/Test.suite/Results/bug2029/20130903_134649.212/Screen_Error.tiff", type:"screenshot" //Connects to a screenshot saved in the suite
You can then run OCR against that image using the approach laid out in the original answer below (i.e. taking images of the top-left and bottom-right of the area you want to read).
If the text you are wanting to read is on the System-Under-Test (SUT) then the recommended approach is to capture two images: one that represents the Top Left corner of the area where you'd like to read text from, and another that represents the Bottom Right. You may want to use a naming convention to make these images easier to identify later, e.g. TextArea_TL and TextArea_BR.
The reason for using images here rather than coordinates is because the text that you are trying to read may move around the screen, and so because Eggplant Functional scans the whole screen for the TL and BR images, the appropriate locations to read text from will still be found (as long as they remain unique).
Using the ReadText() command, you would then write something along the lines of the following:
put ReadText("TextArea_TL", "TextArea_BR")
In this case, this just outputs the text to the console, as can be seen in the Run Results here:

- 155
- 1
- 2
- 9
-
You could also use coordinates directly instead of images as arguments to the `ReadText` command. – sphennings Feb 29 '16 at 23:58
-
But how to read the text on the image for example: I have to read my name on image. – Priyanka Randive Mar 03 '16 at 08:23
-
1See my update: it is not possible to use the OCR outside of the remote screen buffer. Now, you could in theory open the image on the SUT instead, but that may or may not be feasible depending on the SUT that you are working with. – Tom Mar 04 '16 at 23:31