AShot: element screenshots and visual diffing for Selenium tests
WebDriver Screenshot utility. Take screenshots, crop, prettify, compare
At a glance
- What is it?
- AShot is a Java library for taking screenshots of a single WebElement rather than the whole viewport, which is what a visual regression test actually needs. It also decorates those images and compares two of them, with an ImageDiffer that can ignore pixels of a chosen colour.
- Who is it for?
- AShot fits a Java team running Selenium or Appium tests that needs to assert on the appearance of a single component rather than the whole page, and that wants the comparison and the cropping in the same library. It does not fit a team that has moved to a modern visual regression service, and it does not fit drivers with broken JavaScript execution without the alternate coordinates provider.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 10 days ago.
- What is it written in?
- Mainly Java, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Cropping to an element is the whole point
AShot is described as a WebDriver screenshot utility, and the three capability lines are worth reading closely. It takes a screenshot of a WebElement on different platforms, which it names as desktop browsers, iOS Simulator Mobile Safari and Android Emulator Browser. It decorates screenshots. And it provides flexible screenshot comparison. The element view is what distinguishes it. The README describes the process in three steps: capture a screenshot of the entire page, find the element's size and position, and crop the original screenshot. The result is an image of just the WebElement. That is a completely different artefact from a viewport screenshot, and it is the one a component-level visual test needs, because a viewport shot changes whenever anything above or below the component changes, which makes it useless as a regression signal.
Maven coordinates, and the version mismatch to watch
The library is published on Maven Central under the ru.yandex.qatools.ashot group, and the README gives the dependency block.
<dependency>
<groupId>ru.yandex.qatools.ashot</groupId>
<artifactId>ashot</artifactId>
<version>1.5.4</version>
</dependency>That version number is worth a second look, because the listed releases are older. The release history shows 1.5.2 from 2015-12-09, AShot-1.4.12 from 2015-04-03 and ashot-1.4.8 from 2015-03-11, while the README's dependency snippet uses 1.5.4. The repository itself was pushed to on 2026-10-13 and is not archived, so the source is being worked on even though the release tags are old. The project is a Maven build with a pom.xml, a Maven wrapper in mvnw and mvnw.cmd, and a .mvn directory. The licence is one GitHub cannot classify, so the LICENCE file in the repository root is the authority on the terms rather than the badge.
Viewport pasting, and a decorator system for strategies
The hard part of element screenshots is that WebDrivers take screenshots differently. Some provide a screenshot of the entire page while others handle the viewport only, and AShot can be configured to cope with the viewport problem. The configuration is a shooting strategy, and the simplest example gives a full page screenshot even for Chrome and Mobile Safari.
new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(100))
.takeScreenshot(webDriver);There are built-in strategies in ShootingStrategies for different use cases, and when none of them fit, the README says you can build one using existing strategies as decorators or implement your own. The decorator example chains a VariableCutStrategy, wrapped in a RotatingDecorator, wrapped in a ViewportPastingDecorator with a scroll timeout.
CutStrategy cutting = new VariableCutStrategy(HEADER_IOS_8_MIN, HEADER_IOS_8_MAX, VIEWPORT_MIN_IOS_8_SIM);
ShootingStrategy rotating = new RotatingDecorator(cutting, ShootingStrategies.simple());
ShootingStrategy pasting = new ViewportPastingDecorator(rotating)
.withScrollTimeout(scrollTimeout);
new AShot()
.shootingStrategy(pasting)
.takeScreenshot(webDriver);The composition of a cut, a rotation and a paste is the mechanism that makes full-page capture work in a viewport-only driver, and the scroll timeout is the knob that controls how long the driver is allowed to scroll and stitch.
The coordinates problem, and the jQuery dependency
To crop to an element, AShot needs the element's coordinates, and this is where the library has an opinion and an escape hatch. The WebDriver API provides a method to find the WebElement's coordinates, but different WebDriver implementations behave differently. The README says the most general approach is to use jQuery, so AShot uses jQuery by default. But some drivers have problems with JavaScript execution, naming OperaDriver as an example, and in that case there is another way to find the element's coordinates, through a coords provider that uses the WebDriver API instead.
new AShot()
.coordsProvider(new WebDriverCoordsProvider()) //find coordinates with WebDriver API
.takeScreenshot(webDriver, myWebElement);Taking the screenshot of a particular element is otherwise a one-liner, since you just specify the elements.
WebElement myWebElement = webDriver.findElement(By.cssSelector("#my_element"));
new AShot()
.takeScreenshot(webDriver, myWebElement);And you can implement your own CoordsProvider, with pull requests welcome. That extension point matters more than it looks, because the jQuery default is the single most common reason an element screenshot fails on an unusual driver.
Decorating the image so a diff says something useful
By default a plain crop gives you a rectangle on a white page, which is hard to read in a diff. AShot lets you decorate it. The default cropper is DefaultCropper, and the README's example swaps in an IndentCropper with an indent filter that blurs the indented areas, which the README says provides more information about position relative to other elements and focuses attention on the WebElement.
new AShot()
.withCropper(new IndentCropper() // set custom cropper with indentation
.addIndentFilter(blur())) // add filter for indented areas
.takeScreenshot(driver, yandexWeatherElement);The decoration idea generalises. When you screenshot several independent elements at once, the library computes a complex comparison area, so that only the specified elements are focused and will be compared.
List<WebElement> elements = webDriver.findElements(By.cssSelector("#my_element, #popup"));
new AShot()
.withCropper(new IndentCropper()
.addIndentFilter(blur()))
.takeScreenshot(webDriver, elements);The multiple element feature is marked as available since version 1.2, so it has been in the library long enough to rely on.
ImageDiffer, ignored elements, and ignoring a colour outright
The takeScreenshot call returns a Screenshot object containing an image and data for comparison, and the README notes you can ignore some WebElements from the comparison, which is how you exclude a blinking timestamp or a random avatar from a visual assertion.
Screenshot myScreenshot = new AShot()
.addIgnoredElement(By.cssSelector("#weather .blinking_element")) // ignored element(s)
.takeScreenshot(driver, yandexWeatherElement);ImageDiffer is what finds the difference between two images, and it returns a marked image showing where they differ.
ImageDiff diff = new ImageDiffer().makeDiff(myScreenshot, anotherScreenshot);
BufferedImage diffImage = diff.getMarkedImage(); // comparison result with marked differencesThe other lever is a colour to ignore. You can set the colour of pixels which should be excluded from the comparison, and the example uses magenta, with the note that any pixels in the template with that colour, 255, 0, 255 in RGB, are ignored during the comparison.
ImageDiffer imageDifferWithIgnored = new ImageDiffer().withIgnoredColor(Color.MAGENTA);
ImageDiff diff = imageDifferWithIgnored.makeDiff(templateWithSomeMagentaPixels, actualScreenshot);
assertFalse(diff.hasDiff());That is a blunt but effective tool, and it lets a test template mark a region as irrelevant without having to write a custom differ.
Editorial conclusion
AShot fits a Java team running Selenium or Appium tests that needs to assert on the appearance of a single component rather than the whole page, and that wants the comparison and the cropping in the same library. It does not fit a team that has moved to a modern visual regression service, and it does not fit drivers with broken JavaScript execution without the alternate coordinates provider. Verify first that your driver can execute JavaScript, since the default coordinate lookup relies on jQuery being injected, and read the release history before pinning, since the listed tags go back to 2015 while the code has moved on.
Frequently asked questions
How do I add AShot to a Maven project?
Add the ru.yandex.qatools.ashot group with the ashot artifact and version 1.5.4, as shown in the README's dependency block. The project is published on Maven Central.
How do I take a full page screenshot in AShot when the driver only captures the viewport?
Use a shooting strategy. The README's example configures ShootingStrategies.viewportPasting(100), and notes that built-in strategies exist in ShootingStrategies for different use cases, and that you can compose existing strategies as decorators or implement your own.
What if JavaScript execution does not work in my driver?
AShot finds element coordinates with jQuery by default, and the README notes that some drivers have problems with JavaScript execution, naming OperaDriver. In that case you can set a different coords provider, for example new WebDriverCoordsProvider(), or implement your own CoordsProvider.
How do I compare two screenshots in AShot?
Use ImageDiffer. The makeDiff call takes two Screenshot objects and returns an ImageDiff, from which getMarkedImage gives an image with the differences marked. You can also ignore specific elements with addIgnoredElement, or exclude a colour entirely with withIgnoredColor.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/pazone-ashot)Was this useful?