Search This Blog

Breaking

Friday, 24 September 2021

Ashot library to your visual automation in java based project

Though I was very impressed last time when I used webdriverIO visual automation capability, but the flakiness which comes with it, always made me skeptical about relying on it much. And now, when I am again back to java based automation framework, I feel it to give it a try one more time. 

So after searching about the library which can give support the visual capability for a java based project, I came across the Ashot library. I added its dependency in my maven project and started working on a POC. I tried to do a comparison for a static page, specific web element and then a page having dynamic content.










In my local machine, I didn't face any issue, and it worked great. But the one thing, which disappointed me is their support. Looks like, team is not actively maintaining the code. And it might be, that if you will stuck at some place, you wouldn't find support much. 

So if you have a java maven project, add Ashot maven dependency.

<dependency>

    <groupId>ru.yandex.qatools.ashot</groupId>

    <artifactId>ashot</artifactId>

    <version>1.5.4</version>

</dependency>


For capturing an image, you can use below method:

new AShot()
  .shootingStrategy(ShootingStrategies.viewportPasting(100))
  .takeScreenshot(webDriver);


Keep this image in a folder, and then run it again and use it's difference method to find out the difference between the 2 images.

ImageDiff diff = new ImageDiffer().makeDiff(myScreenshot, anotherScreenshot);
You can read the documentation about this project to get more detail about it. And if you have any question,Then let me know. I will be happy to share my learning.

No comments:

Post a Comment