How to Capture ScreenShot of Particular Web-element using selenium aShot

Running Automation Script in Chrome Headless with TestNg

In this blog, we are going to learn, how we can capture the screenshot of particular WebElement using Third-party utility “aShot”.

aShot is 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)
Ø    Capturing Full Page Screenshots.
Ø    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 where I have captured the screenshot of google logo from its web-page.

In the above code takeScreenshot captures the screenshot of given web element, Screenshot is the result of Screen capture.

After executing the above code result will looks something like:



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