How to make EggPlant to click on second duplicate image?


I have multiple dropdown boxes on one page. EggPlant seems to always click on the first one. I know that I can append the co-ordinates to the FoundImageLocation(). Is there a better way (or function that I can use) to make EggPlant to click on the duplicate image on different locations as specified?

Your help is appreciated.

If your dropdowns have labels, then you should use the “relative hotspot” technique. See page 10 of the Using Eggplant manual in the Help.

Otherwise, you can use the EveryImageLocation() function and click the index of the one you want:

click item 2 of everyImageLocation("dropdownboximage")

If there is anything on the GUI that you can use to differentiate the drop-down boxes, then take those images and use them in a switch case or conditional statements. If there is not, see if there is something that you can take an image of that is close to the drop-down box you want to click on, then create an anchor point based on the image hot spot, add x, y values of a search rectangle of the drop down box (AnchorPoint) based on the hot spot, and then click the image of the drop down that is found in the search rectangle.

put ImageLocation(“path to image name”) into AnchorPoint
insert AnchorPoint + [-25, 26] into SR
insert AnchorPoint + [800, 40] into SR

Set the SearchRectangle to SR

click {image: “path to image name”, waitfor: 5}

LogSuccess “Pass: Drop-down button was found and clicked”