コード例 #1
0
  public static void main(String[] args) {
    simulator.start();
    ScreenRegion s = new DesktopScreenRegion();
    URL imageURL = Images.GoogleSearchButton;
    Target imageTarget = new ImageTarget(imageURL);
    ScreenRegion r = s.find(imageTarget);

    canvas.addBox(Relative.to(r).right(100).getScreenRegion());
    canvas.addLabel(Relative.to(r).right(100).center().getScreenLocation(), "right");

    canvas.addBox(Relative.to(r).left(100).getScreenRegion());
    canvas.addLabel(Relative.to(r).left(100).center().getScreenLocation(), "left");

    canvas.addBox(Relative.to(r).above(100).getScreenRegion());
    canvas.addLabel(Relative.to(r).above(100).center().getScreenLocation(), "above");

    canvas.addBox(Relative.to(r).below(100).getScreenRegion());
    canvas.addLabel(Relative.to(r).below(100).center().getScreenLocation(), "below");

    canvas.display(3);

    mouse.click(Relative.to(r).center().getScreenLocation());
    mouse.click(Relative.to(r).topLeft().getScreenLocation());
    mouse.click(Relative.to(r).topRight().getScreenLocation());
    mouse.click(Relative.to(r).bottomRight().getScreenLocation());
    mouse.click(Relative.to(r).bottomLeft().getScreenLocation());
  }
コード例 #2
0
  public static void sikuliClick(LiferaySelenium liferaySelenium, String image) throws Exception {

    ScreenRegion screenRegion = new DesktopScreenRegion();

    ImageTarget imageTarget = getImageTarget(liferaySelenium, image);

    screenRegion = screenRegion.find(imageTarget);

    Mouse mouse = new DesktopMouse();

    mouse.click(screenRegion.getCenter());
  }
コード例 #3
0
  @Test
  public void functionName() throws FindFailed {

    // Create a new instance of the Firefox driver
    WebDriver driver = new FirefoxDriver();

    // And now use this to visit Google
    driver.get("http://www.google.com");

    // Create and initialize an instance of Screen object
    Screen screen = new Screen();

    screen.keyDown(Key.SPACE);
    screen.type(null, Key.SPACE + "n", 0);
    screen.keyUp(Key.SPACE);

    ScreenRegion s = new DesktopScreenRegion();

    Target target = new ImageTarget(new File("C:\\testsuk.sikuli\\GoogleSearch.png"));
    ScreenRegion r = s.find(target);

    // Create a mouse object
    Mouse mouse = new DesktopMouse();
    // Use the mouse object to click on the center of the target region
    mouse.click(r.getCenter());

    System.out.println(r.getBounds());

    // Add image path
    //	Pattern image = new Pattern("C:\\testsuk.sikuli\\searchButton.png");

    // Wait 10ms for image
    //	s.wait(image, 10);

    // Click on the image
    //	screen.click(image);
  }