Hi! I’ve just started using eggplant, so I’m not too familiar with it yet. I apologize if this question or something like it is answered somewhere else… I’ve looked in the documentation and didn’t find anything yet.
Is there a way to capture an image in such a way that you can have Eggplant ‘ignore’ a part of the image? Say I have a combobox that I want to click on, and the title of the box is ‘Status’ (see the attached image). But there is another portion of the screen that has ‘Status’ on it as well, with the same background color, and I’d like to differentiate between the two by selecting the title and the combobox control it is associated with as well. BUT i don’t want to include any selection text that may appear in the box itself (‘Cancelled’ in the image I included). I’d like to select the box’s frame but not it’s contents… in effect ‘ignore’ whats in the box while selecting its frame. Is this possible? If not, what’s a good way to get around this problem?
What you ask is technically possible, but not entirely from within Eggplant. You can take a captured image and using a third party tool like Graphic Converter or Photoshop, apply an alpha mask to the part of the image that you want Eggplant to ignore. However, I’m not sure that this is the best solution to your problem.
I don’t know what the other “Status” on your screen is near, but if it’s not next to another combobox, you might just be able to include the left edge of the combo box in your image and that would be adequate for Eggplant to differentiate between the two occurrences.
You could do an EveryImageLocation() call on your image of the status text and given that Eggplant scans left to right and top to bottom, you could infer that either the first or the last location in the returned list (assuming only two occurrences) is the one that you want. This approach would need to assume that their relative postions are not going to change at some point in the future.
Another approach would be to set the search rectangle (the area on the screen that Eggplant searches) in such a way that it excludes the “status” label that you are not interested in. If you can identify two images that would represent opposite corners of a rectangle surrounding the “status” text that you want to work with, then you can make a call like this:
setSearchRectangle( imageLocation("image1"), imageLocation("image2"))
// do the click here
setSearchRectangle() // resets the search area to the whole screen
there are a number of variations on how to specify the search rectangle, including hard coding the bounding points or deriving them by adding or subtracting coordinates from a known point. Also, in the recently released Eggplant 1.5, you can specify a search rectangle on an image-by-image basis by using a property list, for example:
Click(imageName:"status", searchRectangle: (100,100,200,200))
I hope this gets you pointed in the right direction.
Thanks! I actually have been using the method of including the left border of the combo box since I last posted. The other solutions are interesting, too, though. I’ll keep them in mind for future problems.