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.
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
Hello,
ReplyI 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
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