Image and OCR Searches
These commands and functions execute image or optical character recognition (OCR) searches on the system under test (SUT).
You can further control the search behavior of the image and OCR search commands and functions below by using the ImageSearchCount, the ImageSearchDelay, and the ImageSearchTime global properties.
EveryImageLocation Function
Behavior: Searches the SUT for all occurrences of the given images or text (OCR); returns a list of the hot spot coordinates for every occurrence of the images, or a list for the center of the text string when using OCR. Coordinates are listed in the order in which they are found, where images and text closest to the top left corner of the SUT are found first. If no image or text (OCR) is found, EveryImageLocation returns an empty list.
Parameters: One or more Image References or properties, or Text Properties (for OCR).
Syntax:
EveryImageLocation( imageOrTextReference )
Returns: The coordinates of every instance of the given image or images. For example:
[[288,325],[288,356],[288,387],[288,448]]
Example:
Including the ImageName property is required when passing additional image search properties as in this example.
log EveryImageLocation(ImageName:"CheckBoxes",scale:[1,.5]) // Logs a list of hot spot coordinates for every occurrence of the image found at both the original size and half scale. Note the use of the ImageName property when including additional properties for the image search.
Example:
click the penultimate item of EveryImageLocation(text:"AddressField") // Clicks the penultimate (second to last) item in the list of occurrences of the text (OCR).
Example:
set the RemoteWorkInterval to .1 // Shortens the RemoteWorkInterval (default=.7) to decrease the pause between actions that Eggplant Functional sends to your SUT. This change allows the series of clicks to execute much faster.
repeat with EveryImageLocation("RadioButton") // Iterates through each occurrence of the image found with everyImageLocation().
click it // Using the it variable, clicks the current occurrence the repeat loop is operating on.
end repeat
set the RemoteWorkInterval to .7
Example:
// The following example provides an alternate syntax for the previous example.
repeat with each item of EveryImageLocation("RadioButton")
click it // Using the it variable, clicks the current occurrence the repeat loop is operating on.
end repeat
When you call the EveryImageLocation function, you can immediately call the result to return ImageInfo for every image represented in EveryImageLocation.
Example:
put EveryImageLocation("GreenSaveButton","BlueSaveButton","RedSaveButton") // Returns a list of hot spot coordinates for every occurrence of the image.
put the result // Returns imageInfo for every image represented in EveryImageLocation.
EveryImageRectangle Function
Behavior: Searches the SUT for all occurrences of the given images or text (OCR); returns a list of the rectangle coordinates for every occurrence of the images or text (OCR). Coordinates are listed in the order in which they are found, where images and text closest to the top left corner of the SUT are found first. If no image or text (OCR) is found, EveryImageRectangle returns an empty list.
Parameters: One or more Image References or properties, or Text Properties (for OCR).
Syntax:
EveryImageRectangle( imageOrTextReference )
Returns: The rectangle coordinates of every instance of the given image or images.
Example:
put EveryImageRectangle("TotalAmountLabel", "ItemizedAmountLabel") // Returns a list of rectangle coordinates for every occurrence of the images.