← Back to team overview

sikuli-driver team mailing list archive

[Question #272390]: Sikuli finds only first match in a sequence

 

New question #272390 on Sikuli:
https://answers.launchpad.net/sikuli/+question/272390

Hello, I'm new to test automation, java and sikuli, so I could be doing something wrong. 
In my tests I'm limited to use only screenshots, so I can't use Screen or Region of the device itself.

I run a method in "for" cycle to perform actions in a sequence. I do that by finding an element on the screenshot (which updates every "for" tick).

The method itself:

 public void FindMatch(int num) throws FindFailed
    {
        _currentMatch = null;
        if (_driver!=null)
        {
            File screenShot = ((TakesScreenshot)_driver).getScreenshotAs(OutputType.FILE);
            try
            {
                FileUtils.copyFile(screenShot, new File (_currentScreenshotPath+"cs.jpg"));
                Finder f = new Finder(_currentScreenshotPath+"cs.jpg");
                Pattern p = new Pattern("/Users/user/Documents/TestFolder/MasterScreens/pattern"+num+".jpg");
                f.find(p);
                Match currentMatch = f.next();
                if (currentMatch!=null)
                {
                    System.out.println(currentMatch + " match " + num + " found");
                    _currentMatch = currentMatch;
                }
                else
                {
                    System.out.println("Match wasn't found");
                }
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
    }

Everything works fine until it hits second iteration, then f.next() returns null.
Images aren't the problem, I switched elements names and everything worked in the first iteration as well. _currentScreenshot works fine too. 
So at the moment I have no idea what's wrong and where too look for. I'd be glad if someone could help me.

Thanks in advance.


-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.