sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #35108
Re: [Question #272390]: Sikuli finds only first match in a sequence
Question #272390 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/272390
Description changed to:
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 what to 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.