CompareImages { public CompareImages(File localFile, WebElement remoteImage, WebDriver driver) throws Exception { this.localFileObject = new FileHandler(localFile); this.remoteImageObject = remoteImage; this.driver = driver; } CompareImages(File localFile, WebElement remoteImage, WebDriver driver);  CompareImages(String localFile, WebElement remoteImage, WebDriver driver); void changeLocalFileTo(File localfile); void changeLocalFileTo(String localfile); void changeRemoteImageTo(WebElement remoteImage); File getLocalImage(); WebElement getRemoteImageWebElement(); Boolean compareImages();  }
@Test public void compareMatchingImagesUsingFile() throws Exception { driver.get("http: File localImage = new File(this.localImage.toURI()); WebElement remoteImage = driver.findElement(By.id(locator)); CompareImages imageCompare = new CompareImages(localImage, remoteImage, driver); assertThat(imageCompare.compareImages(), is(equalTo(true))); }
@Test public void compareMatchingImagesUsingString() throws Exception { driver.get("http: String localImage = this.localImage.toURI().getPath(); WebElement remoteImage = driver.findElement(By.id(locator)); CompareImages imageCompare = new CompareImages(localImage, remoteImage, driver); assertThat(imageCompare.compareImages(), is(equalTo(true))); }
@Test public void compareDifferentImagesUsingFile() throws Exception { driver.get("http: File localImage = new File(this.wrongLocalImage.toURI()); WebElement remoteImage = driver.findElement(By.id(locator)); CompareImages imageCompare = new CompareImages(localImage, remoteImage, driver); assertThat(imageCompare.compareImages(), is(equalTo(false))); }
@Test public void compareDifferentImagesUsingString() throws Exception { driver.get("http: String localImage = this.wrongLocalImage.toURI().getPath(); WebElement remoteImage = driver.findElement(By.id(locator)); CompareImages imageCompare = new CompareImages(localImage, remoteImage, driver); assertThat(imageCompare.compareImages(), is(equalTo(false))); }