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