In Eggplant we have a option to select a search rectangle and find a image within the rectangle, as below:
Click ( imageName: “myImage”, searchRectangle: ( 0, 0, 200, 200 ) )
I would like to know is there any way by which we can find and click a set of images within the boundary/searchrectangle. :!:
Also please explain how to find out the coordinates to set the searchRectangle :?:
"I would like to know is there any way by which we can find and click a set of images within the boundary/searchrectangle. "
I’m not sure what you mean by clicking “a set of images”. The command you gave is correct for finding a single image within a restricted area and clicking it.
“Also please explain how to find out the coordinates to set the searchRectangle.”
The imageLocation() function will return the coordinates of an image on the screen. So one way to do this is to capture images of two corners of the area in which you want to constrain the search (it may be helpful to keep in mind that you can reposition the HotSpot of an image to any place relative to the image). A rectangle can be specified using two points, so you could set the searchRectangle like this:
set the searchRectangle to (imageLocation("TopLeft"), imageLocation("BottomRight"))
You can also calculate one coordinate from another. For example, you might use an image to find the top left corner, then set a rectangle that is 200 pixels wide and 100 pixels tall like this:
put imageLocation("TopLeft") into topLeftCorner
set the searchRectangle to (topLeftCorner, topLeftCorner+(200,100) )
Actually my intension is to click on a image in a restricted area of the application which changes over period of time. let me explain this with an example: Say there’s a button whose appearance changes after click or on selecting it. And i have to click on the button(no matter its appearance changes) again and again after some duration. So since the appearance of button changes, i have captured all the images of the button and at the time of clicking on it, i want to find one image from number of images captured for the button in the restricted search area and click on it.
To search one image in restricted area is known to me, but i’m not getting the method to do the above mentioned. I tried giving “ClickAny” instead of “Click” and list of image names separated by commas in “imageName:”, but it didn’t work.
Please tell me an alternative solution to do it.
ClickAny should do the trick for you, but you can’t put the list of image names in the “imageName:” property when you’re using a property list. Using that approach your code would have to look like this:
ClickAny (imageName:"image1", searchRectangle:rect), (imageName:"image2", searchRectangle:rect)
For this situation that gets a little unwieldy, though, so I suggest you use the setSearchRectangle command instead of using property lists in the ClickAny:
ClickAny "image1", "image2"
setSearchRectangle -- restore to full screen
If you are certain that the image’s location will not change over time (although it’s appearance does, as you indicated), you might consider simply putting the image’s location into a variable. You can then click that image location (variable value) later. Your code could look something like this:
ClickAny "icon_state1", "icon_state2", "icon_state3"
put foundImageLocation() into iconLocation
//do more testing
//when you need to click on the icon again, no matter what it currently looks like:
This approach is okay if you are not concerned with the actual “state” of the icon.