Documentation
This page contains information about EyeSel.
API Documentation
Click here to view the API Documentation.
Examples
Small examples of how to use the EyeSel API from Java. The examples are almost identical to the Eye examples. The only difference is that the setWebDriver method is used to provide the WebDriver to use and the EyeSel license key. Images are located and compared from within the browser instead of the entire desktop.
public boolean clickImageExample(String imagePath, WebDriver webDriver, String licenseKey) { // Create an Eye Eye eye = new Eye(); eye.setWebDriver(webDriver, licenseKey); // Load the image to locate BufferedImage image = eye.loadImage(imagePath); if (image != null) { // Locate the image inside the browser Match match = eye.findImage(image); if (match != null) { // A match - click in the center of the image if(eye.click(match.getCenterLocation())) { return true; } } } return false; }
public boolean compareImageExample(String imagePath, WebDriver webDriver, String licenseKey) { // Create an Eye Eye eye = new Eye(); eye.setWebDriver(webDriver, licenseKey); // Load the image to locate BufferedImage image = eye.loadImage(imagePath); if (image != null) { // Locate the image and compare if identical Listrectangles=eye.compare(image); if(rectangles.size()>0) { // There are differences - create an image that shows the differences BufferedImage imageDiff=eye.createRectangleImage(image, rectangles, Color.red); // Save the image Eye.savePngImage(imageDiff, "filediff.png"); return false; } // The images are identical return true; } return false; }
public boolean checkImageExample(String imagePath, WebDriver webDriver, String licenseKey) { // Create an Eye Eye eye = new Eye(); eye.setWebDriver(webDriver, licenseKey); // Load the image to check BufferedImage image = eye.loadImage(imagePath); if (image != null) { // Define a target area that will be checked in detail Rectangle targetArea=new Rectangle(0, 0, 20, 20); // Locate the image inside the browser Match match = eye.findImage(image, targetArea); if (match != null) { return true; } } return false; }