Tuesday, August 15, 2017

How to take screenshot of WebElemets in Selenium?

In the previous post AShot() in Selenium 3 for taking full page screenshot? we have seen how to capture the full page screenshot in Selenium using AShot() utility. Now we will see how to capture the screenshot of WebElement using AShot().

Syntax: The below method is used to capture the screenshot of the web element.
  • We need to pass two arguments to the above method, one is WebDriver object and another is web element . 
aShot will find element's size and position and crop original image. WebDriver API provides a method to find the WebElement's coordinates  but different WebDriver implementations behave differently.

Step 1: Download AShot() and Selenium Standalone. Add this two jar files to the project.
Step 2: The below sample test launches Selenium Babu blog and captures the screenshots of  Total Pageviews and Title Logo.
Step 3: Checkout the below video for better understanding.

No comments:

Post a Comment

DevOps 01: What is DevOps and How it benefits organizations?

DevOps is a culture in an organization, where the development team and operations team help each other by sharing information, process and t...