Text recognition

Does Eggplant do text recognition? For example I got a list box and bunch of values in it. I would like to scoll down and find the right item and select it. How I can do this in Eggplant?

Thanks

One method of selecting a value within a list box is to click on the list box and type the value that you want selected. Not all boxes however, behave like this, so in those situations you must first have a captured image of the value that you want to select before you can have Eggplant select it. Once you have this value captured as an image you can continuously scroll within a loop to find the appropriate value that you want to select. It’s also a good idea to use a visual indicator or some other approach to determine if you have reached the button of the list. Otherwise, your script will loop forever if Eggplant doesn’t find your captured image of the value that you want to select.


repeat 
   if imageFound("value") then
      Click foundImageLocation()
      exit repeat
   else if imageFound("endList") then
      Log "Value not found"
      exit repeat
   end if

   TypeText downArrow  -- or whatever you use to scroll

end repeat

When in doubt, just think of how a real person would perform the task: given a visual perspective that is. :wink:

Now that Eggplant version 3.0 is available, we can answer “Yes” to finding text images. This will allow you to find a text item in a list without having to capture an image of it in advance.

The basic technique used for navigating a scrollable list will stay the same, but using a text image instead of a captured image can help to make your code more modular and reusable.

Here’s an updated version of the script that Jo posted above:

(* SelectListBoxItem.script *)
params itemToSelect
repeat 
   if imageFound(text:itemToSelect, textStyle:"ListBoxItem") then 
      Click foundImageLocation() 
      exit repeat 
   else if imageFound("endList") then 
      Throw "ListBoxException", "Value not found:" && itemToSelect
   end if 

   TypeText downArrow  -- or whatever you use to scroll 

end repeat

Here, itemToSelect is a variable containing the text of the item you want to select, and “ListBoxItem” is the name of a style that defines the font, size, color, etc. of text within a list box.

If you save the code above as a script called “SelectListBoxItem”, it can be called as a command any time you need to select something in a list, like this:

SelectListBoxItem "Orange"