OCR reads Eggplantl instead of Eggplant1

Fairly new to Eggplant, so apologies if this is a newbie question. I am having a slight issue with OCR. When reading a username “Eggplant1” from the SUT, OCR mistakes the number 1 for the lowercase letter l and I end up with “Eggplantl”. The username, which will be outwith my control does not have a set format, so I can’t configure a valid pattern. I have manipulted the contrast and the resolution of the SUT but I still end up with the same result. Will a ValidCharacters parameter help this? Any help would be greatly appreciated.


I’ve had similar issues with text. My usual trick would say look for “Eggplant” and skip the last letter. But I see you’re dealing with usernames so that may not be a good option.

First, please send questions like this to support unless you’re really looking for the community to provide you with the answer. Second, there is no way (other than the pattern which you’ve mentioned won’t work for your scenario) to have the OCR recognize the 1 as a 1. There’s no context for the OCR to expect a 1 at the end of a series of letters. You need to be aware of the “R” in OCR, which is “recognition” – the OCR is looking at the pixels on the screen and trying to find things that might be letters. It’s not like an object-based approach where text can be extracted and the test tool told what the characters are (whether they’re readable or even visible to the user.) I can be reasonably sure that if you zoom in on the characters, you would see that they are much fuzzier and less distinct at the pixel level than they appear to you when you look at the screen. So unfortunately, this is a case where readText() is unlikely to return the result you want. It might be a case where if the objective is to validate that “Eggplant1” is displayed, you could look for the text “Eggplant1” rather than reading it.

Scott, can you change the font in the app? Perhaps something with the l and 1 are more distinct?

Is your text live (i.e. can you select it on the screen by ‘highlighting it’?) If so, give this a try:

// Highlights text to the right of an image and returns the highlighted value
function HighlightTextAdjacentToImage myImageName, myDragDropOffsetX, myDragDropOffsetY, myDragDropDistance
if myDragDropOffsetX is “” then set myDragDropOffsetX to 3
if myDragDropOffsetY is “” then set myDragDropOffsetY to 0
put ImageRectangle(imageName:myImageName, waitFor:5) into myDragDropMarker
set myDragDropStartX to item 3 of myDragDropMarker + myDragDropOffsetX
set myDragDropStartY to round(the average of (item 4 of myDragDropMarker,item 2 of myDragDropMarker)) + myDragDropOffsetY
set myDragDropFinishX to myDragDropStartX + myDragDropDistance
set myDragDropFinishY to myDragDropStartY
Drag ( myDragDropStartX, myDragDropStartY)
Drop ( myDragDropFinishX, myDragDropFinishY)
TypeText controlKey,"c"
set thevalue to RemoteClipboard()
return thevalue
end HighlightTextAdjacentToImage