I have captured some images and compare these images. Now some images have a difference of 1 or 2 pixel in the RGB- color space. Is there a possibility to enter a tolerance to compare images?
The standard Eggplant “Tolerant” search type allows quite a bit of tolerance for variation of colors. When capturing an image, Eggplant will normally set it to use this type of search (except in rare cases where the captured image has very low contrast).
If an image is imported into a suite from an external source, it may be initially set to use the “Precise” search type. You can change this by selecting the image in the Images tab, opening the Info drawer (by clicking the “i” icon in the top-right corner of the Suite window) and selecting a different search type from the popup list in the drawer.
You can adjust the level of tolerance used for each image, if necessary. There are also ways to control the tolerance for each individual search (overriding the setting for an image), and to set different levels of tolerance for the red, green, and blue values of the color. But most of the time, just choosing the Tolerant search type will work well. Let us know if that resolves your problem.
You can use
Click ( ImageName: aName, Tolerance: aValue ) Click ( ImageName: aName, Tolerance: (r,g,b)) Click ( ImageName: aName, Discrepancy: X%)
where r,g,b are allowable point value differences for each specific color vector. The aValue would apply for R, G, and B. Finally the last approach is where maybe a image has transparency and the background changes a X% amount as a result.
Many thanks for the code. That is exactly what I have been.
Can you help me a little bit with the placement in the script, because for me it does not work properly.
if imagefound (12, “RefImages”/& aName) then
Log “Passed” & aName
Log" Failed" & aName
When I put the code in the script I get the message “Can not open file”
That error indicates that the image name you’re using is incorrect (there is no image file by that name). The code you posted doesn’t look quite right (I suspect it’s not exactly what you’re running) but check it carefully to see what name is being passed to the imageFound function. The error message should tell you the file name that Eggplant can’t open.
You are using “aName” as a variable. If you add this line to your script before the call to imageFound(), you can see the value of that variable when your script runs:
put "aName=" & aName
OK, i guess this is a missunderstood. Sorry, my bad english …
The code I?ve posted is ok. It works fine and the image is open.
This is how it works now… but I want to have a Tolerance for some images and I use the code that Todd has posted:
click (imageName: aName, Tolerance: (x,x,x))
And my Problem is that the Error message “Can not open File” comes out… but the image is open in this moment. So, I guess the placement in the Script is not ok.
Now I test the tolerance with the “i” icon from the suite.
I’m not sure I understand exactly what the problem is. If you can post the full text of the error message, and the part of your script where the error occurs, we may be able to help you better.
Meanwhile, here is some more information about setting the tolerance for an image search:
The simplest way to set tolerance for an image is to select the image in the Images tab of the Suite window, click the “i” button to open the Info drawer and set the Search Type to “Tolerant”. This will ensure that the standard tolerance is used (45, unless you’ve changed it in your Preferences). If you want to increase the tolerance for that image, you can enter a different value in the Tolerance field.
If the image’s name is “OKButton”, then you can search for it using the tolerance you’ve specified for that image and click it by simply saying:
If you want to sometimes look for OKButton with one tolerance, and sometimes with a different tolerance, you can override the tolerance for an individual command like this:
Click (imageName:"OKButton", tolerance:60)
When you override the tolerance, you can specify individual tolerance values for the red, green, and blue components of the color instead of using a single value:
Click (imageName:"OKButton", tolerance:(60,10,45))
I hope that helps to clarify how to use the override feature.
I think that the error message you’re getting is indicating that the image name you specified (“OKButton” in my examples) is not being found in the Images folder in your suite. If you can’t figure this out, please post more details.