Full Page Screenshot Using Selenium utility -aShot


Full Page Screenshot Using Selenium utility -aShot

In this Blog, we are going to learn how we can take a full-page screenshot in Selenium Using Third-party utility known as ‘aShot’.

Before Going Further Let's Understand What is aShot.

aShot is a third party web driver screenshot utility used for:

ร˜  Takes a screenshot of a WebElement on different platforms (i.e. desktop browsers, iOS Simulator Mobile Safari, Android Emulator Browser)

ร˜  Decorates screenshots
ร˜  Provides flexible screenshot comparison



Please Visit aShot official page for more details.

Below Steps, we need to follow to use aShot in our Project.

ร˜ Download aShot Jar or Maven dependency using this link.

The dependency that I am using for implementation.


ร˜  Please refer below code snippet for implementation details.

After executing the above code result will look something like:



Below is the code explanation:

ShootingStrategiesร  It is a built-in strategy for different use cases. In case there are no suitable strategies it is possible to build it using existing strategies.

viewportPasting ร It will scroll viewport while shooting this

1000 (Configurable value)ร scrollTimeout time between viewportPasting scrolls in milliseconds.



takeScreenshot ร Takes the screenshot of the whole page.

ImageIOร  A class containing static convenience methods for locating ImageReaders and ImageWriters, and performing simple encoding and decoding.

Writeร Writes an image using an arbitrary ImageWriter that supports the given format to a File. If there is already a File present, its contents are discarded.

D://Screen//FullPageScreenshot.pngร Path where we want to Store Screenshot

Happy Learning J



SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
Anonymous
June 2, 2020 at 8:31 PM

Hello,

I am using following code;
Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);

I am getting exception;
java.lang.NoSuchMethodError: org.apache.commons.io.IOUtils.toString(Ljava/io/InputStream;Ljava/nio/charset/Charset;)Ljava/lang/String;

I have added following required dependency;

commons-io
commons-io
2.6
Can you please help me to resolve this? Thanks

Reply
avatar
October 14, 2021 at 4:42 PM

I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it.. Page Unresponsive

Reply
avatar