org.sikuli.script.FindFailed Java Examples

The following examples show how to use org.sikuli.script.FindFailed. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertyEditor.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private List<Shape> getMatchesList() {
    List<Shape> rMatches = new ArrayList<>();
    try {
        Iterator<?> it = getMatches();
        if (it != null) {
            Region sRegion = Region.create(shapes.get(0).getBounds());
            while (it.hasNext()) {
                Object region = it.next();
                Shape rx = ((Region) region).getRect();
                if (sRegion != null && sRegion.getRect().contains(rx.getBounds())) {
                    rMatches.add(rx);
                }
            }
        }

    } catch (FindFailed | IOException | NullPointerException ex) {
        Logger.getLogger(PropertyEditor.class.getName()).log(Level.SEVERE, null, ex);
    }
    return rMatches;
}
 
Example #2
Source File: ElementImageTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Test
  public void test090_ImageFindResizeUp() {
    testIntro();
    Image shot = new Image(testBaseX2);
    Assert.assertTrue("", shot.isValid());
    Match match = null;
    Settings.AlwaysResize = 2;
    try {
      match = shot.find(testName);
    } catch (FindFailed findFailed) {
    }
//    Image.resetCache();
    testOutro("%s in %s is %s", testName, shot, match);
    Assert.assertNotNull(testName + " not found in " + testBaseX2, match);
  }
 
Example #3
Source File: AndroidRegion.java    From sikuli-monkey with MIT License 5 votes vote down vote up
@Override
public <PSRML> Location getLocationFromPSRML(PSRML target) throws FindFailed {
    Location loc = super.getLocationFromPSRML(getAlternativePS(target));
    if (target instanceof Pattern) {
        Location offset = ((Pattern)target).getTargetOffset();
        loc.translate(offset.x, offset.y);
    }
    return loc;
}
 
Example #4
Source File: AndroidRegion.java    From sikuli-monkey with MIT License 5 votes vote down vote up
@Override
public <PSC> Iterator<Match> findAllNow(PSC target) throws FindFailed {
    Iterator<Match> all = super.findAllNow(getAlternativePS(target));
    ArrayList<Match> wrappers = new ArrayList<Match>();
    while (all.hasNext())
        wrappers.add(newMatch(all.next()));

    return wrappers.iterator();
}
 
Example #5
Source File: AndroidRegion.java    From sikuli-monkey with MIT License 5 votes vote down vote up
@Override
public <PSC> Iterator<Match> findAll(PSC target) throws FindFailed {
    Iterator<Match> all = super.findAll(getAlternativePS(target));
    ArrayList<Match> wrappers = new ArrayList<Match>();
    while (all.hasNext())
        wrappers.add(newMatch(all.next()));

    return wrappers.iterator();
}
 
Example #6
Source File: PropertyEditor.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private Iterator<?> getMatches() throws FindFailed, IOException {
    if (refImageLocation.exists()) {
        Finder localFinder;
        localFinder = new Finder(refImageLocation.getAbsolutePath());
        localFinder.findAll(new Pattern(imageLocation.getAbsolutePath()).similar(tempObject.getPrecision()));
        return localFinder;
    } else {
        return null;
    }

}
 
Example #7
Source File: ElementImageTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Ignore
public void test110_ImageFindTrans() {
  testIntro();
  Image shot = new Image(testBase);
  Match match = null;
  try {
    match = shot.find(testNameTrans);
  } catch (FindFailed findFailed) {
  }
  testOutro("%s in %s is %s", testName, shot, match);
}
 
Example #8
Source File: ElementImageTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Test
public void test100_ImageFind() {
  testIntro();
  Image shot = new Image(testBase);
  Match match = null;
  try {
    match = shot.find(testName);
  } catch (FindFailed findFailed) {
  }
  testOutro("%s in %s is %s", testName, shot, match);
  Assert.assertNotNull(testName + " not found", match);
}
 
Example #9
Source File: ElementImageTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Test
public void test092_ImageFindResizeDown() {
  testIntro();
  Image shot = new Image(testBase);
  Assert.assertTrue("", shot.isValid());
  Match match = null;
  Settings.AlwaysResize = 0.5;
  try {
    match = shot.find(testNameX2);
  } catch (FindFailed findFailed) {
  }
  Image.resetCache();
  testOutro("%s in %s is %s", testName, shot, match);
  Assert.assertNotNull(testNameX2 + " not found", match);
}
 
Example #10
Source File: ElementImageTest.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Test
public void test091_ImageFindResizeOff() {
  testIntro();
  Image shot = new Image(testBase);
  Assert.assertTrue("", shot.isValid());
  Match match = null;
  Settings.AlwaysResize = 1;
  try {
    match = shot.find(testName);
  } catch (FindFailed findFailed) {
  }
  testOutro("%s in %s is %s", testName, shot, match);
  Assert.assertNotNull(testName + " not found", match);
}
 
Example #11
Source File: VNCScreen.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Override
protected Location getLocationFromTarget(Object target) throws FindFailed {
  Location location = super.getLocationFromTarget(target);
  if (location != null) {
    location.setOtherScreen(this);
  }
  return location;
}
 
Example #12
Source File: AndroidScreen.java    From sikuli-monkey with MIT License 4 votes vote down vote up
public <PSRML> int type(String text) throws FindFailed {
    return _robot.type(text);
}
 
Example #13
Source File: AndroidRegion.java    From sikuli-monkey with MIT License 4 votes vote down vote up
public <PSRML> int tap(PSRML target) throws FindFailed {
    Location loc = getLocationFromPSRML(target);
    _robot.tap(loc.x, loc.y);
    return 1;
}
 
Example #14
Source File: AndroidRegion.java    From sikuli-monkey with MIT License 4 votes vote down vote up
public <PSRML> int longPress(PSRML target) throws FindFailed {
    Location loc = getLocationFromPSRML(target);
    _robot.longPress(loc.x, loc.y);
    return 1;
}
 
Example #15
Source File: AndroidRegion.java    From sikuli-monkey with MIT License 4 votes vote down vote up
public <PSRML> int pan(PSRML arg0, PSRML arg1) throws FindFailed {
    return super.dragDrop(arg0, arg1);
}
 
Example #16
Source File: AndroidRegion.java    From sikuli-monkey with MIT License 4 votes vote down vote up
@Override
public <PSC> Match find(PSC target) throws FindFailed {
    return newMatch(super.find(getAlternativePS(target)));
}
 
Example #17
Source File: AndroidRegion.java    From sikuli-monkey with MIT License 4 votes vote down vote up
@Override
public <PSC> Match wait(PSC target, double timeout) throws FindFailed {
    return newMatch(super.wait(getAlternativePS(target), timeout));
}