2
votes

Looking at Sikuli (in conjunction with Selenium) as a possibility for automating the more visual elements of our UI testing, in particular issues that may crop up when the expected branding is not applied.

In my test, I have a white navigation icon image sat on a purple nav bar. I take a screen grab of the white icon sat on it's purple background and that is used as my Pattern in the Sikuli test class. If I then change the CSS in my web app so the nav bar is red, I want the test to fail.

Unfortunately, the background colour change is ignored and the icon is clicked regardless. If I set the pattern's similarity value to 1f (i.e. an exact match), the icon is not clicked. However, it also does not clicked the icon if I change the nav bar colour to the correct purple so it matches the icon screenshot I am using for the pattern.

A "similar" parameter value of anything from 0 to 0.9 lets the test pass once again, regardless of the nav bar colour.

Is this a restriction in the ability of Sikuli or am I missing something?

Edit:

So I found THIS ANSWER to a similar question and it prompted me to check the score returned when trying to match the white icon on red pattern and the white icon on purple pattern to the web page which had the purple branding. The score for both was over 0.9, with the difference from about the second decimal place onward, hence the match of both when I set the "similar" property of the pattern to 0.9.

It prompted me to try increasing the area of the screen shot to include more background relative to the icon size. This resulted in a score of 0.9x for the white on purple pattern and 0.7x for the white on red pattern.

So my conclusion is that the matching does take account of the background colour but if the majority of the screenshot pattern you are using is the same colour, the difference in score is minute.

1

1 Answers

0
votes

Can you bypass the background directly behind the icon and look to the side of it? Excuse my lack of coding knowledge just trying to help come up up with a work-around

exists (icon):
    if exists(whitebg): #capture a small area with just the color near the icon
        pass
    if exists(redbg):
        fail