← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #204354]: Use testing methods in Eclipse

 

Question #204354 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/204354

    Status: Open => Answered

RaiMan proposed the following answer:
--- if it is on Mac:
using Safari in fullscreen mode is not supported yet (if you use it ;-)

--- similar(0.2) ...
... does not make much sense.
Sikuli's matching works pixel by pixel and a lower similarity only means, that some of the pixels only differ in brightness or color. But the pixel structure as such must be the same.
Similarity does not mean, that parts of the image are ignored with lower similarity.
So when using Sikuli in its standard approach you have images that are smaller (in most cases much smaller) the the region they are searched in.
Here the goal is, to get similarity scores between 0.9 and 1.0, to be sure the image is really the one you are looking for (e.g. to click on it).

e.g. if you had made a screenshot of the inactive Safari window (window buttons inactive) and search it on the screen where the same Safari window would have active buttons, it would be found with a similarity towards 0.9.
visible with inactive buttons this should give a similarity towards 1.0.
But the probe must be the same size as the visible Safari window or at least a part of it that is the same pixel by pixel. 
It normally does not make sense, to capture windows with its frames, since only one pixel difference in size would lead to not found.

It is another case, if you want to compare images (the image probe has
the same size as the search area). This is usually used, to check,
wether a whole area on the screen is the same as the shot that was made
with a previous run (regression testing).

--- your case
this is how it should be in Sikuli IDE (which is Python level):

import os
switchApp("Safari")
dir = "/path/to/screens/" # r not needed here
if exists(os.path.join(dir, "test2.png")): # by default the whole screen is searched anyway
    print "found"
else:
    print "not_found"

If you want to use addImagePath in the IDE, you have to avoid that the same entry is added with every rerun again (see docs).
if you only have one image repository, the setBundlePath() might be an alternative.

--- BTW:
this is never needed in main scripts
from sikuli.Sikuli import *

this is only for internal use (regression testing of Sikuli itself) and has nothing to do with unit testing
from sikuli.SikuliTest import *

if you are interested in unit testing on the Python level:
look faq 1804

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.