Automated Visual Testing with aShot

What is aShot?

aShot is a WebDriver screenshot utility. It has been around for a while and widely used. It is the preferred choice of Selenium users for capturing full-page screenshots for years. Many automation engineers might be using aShot to capture screenshots to send them to tools like Applitools.

How can it help?

aShot’s takeScreenshot() method returns a screenshot object which contains the image and data for comparison. You can use ImageDiffer to compare the two images and report the differences. Take screenshots of your base (expected design) and the test page as you would normally do.

//Take Screenshots
Screenshot screenshot = new AShot()
ImageIO.write(screenshot.getImage(), "PNG", new File("./img/" + driver.getTitle() + ".png"));
//Compare Base vs. Test Screenshots
BufferedImage expectedImage = File("./img/base.png"));
BufferedImage actualImage = File("./img/test.png"));
ImageDiffer imageDiffer = new ImageDiffer();
ImageDiff imageDiff = imageDiffer.makeDiff(expectedImage, actualImage);
ImageIO.write(imageDiff.getMarkedImage(), "PNG", new File("./img/aShot_Result.png"));
Assert.assertFalse("Visual differences found!", imageDiff.hasDiff());

Benefits of using aShot for visual testing

  • Free, Open-Source and Simple to use
  • It is already a part of most WebDriver automation frameworks for screenshot capture, hence it can be easily extended for image comparison as well.
  • Use aShot’s inbuilt capabilities to capture independent elements for better comparison rather than the whole page.
  • Quickly identify if there are any visible differences.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Siva Ganesan ~ Testing Chief

Siva Ganesan ~ Testing Chief


Hardcore Software Tester! An advocate for enhancing quality in software using Test Automation.