Saturday, July 29, 2017

AShot() in Selenium 3 for taking full page screenshot?

As discussed in Important notes about Screenshots in Selenium 2 and Selenium 3 we can take only visible area screenshot using TakesScreenshot interface.

Ashot() is a third party utility supported by Selenium WebDriver to capture the screen shots. The below are the features supported by aShot() utility with repect to screenshots:
  • Capturing the entire page
  • Capture the Web Element
  • Prettifying the screenshot
  • Screenshot comparison
  • Several elements comparison
Our focus here is on capturing the entire page and capturing the web element screenshots. For more deatils on aShot() you can refer here.

To take the full page screenshot of a page AShot() scrolls down the page at particular time intervals “scrollTimeOut” till the bottom of the page and takes the screenshot of entire page.

Using shootingStrategy() method Ashot() takes the entire page screenshot. The syntax is:

Here, “scrollTimeOut” time interval. If scrollTimeOut is 1000 ms, AShot() scrolls for every 1000 ms till the bottom to capture the image. You can observe that during script execution.

And the below line of code is to save the screenshot in the desired location.

Let us see now how to implement it.

Step 1: Download AShot () jar file from here and add it to the project.

Step 2: Create a simple test, below is the test that launches ‘Selenium Babu’ blog and takes it's full page screenshot.

Step 3: The screenshot will be saved in the “screenshots” folder in the project directory. The below video shows the execution of the script and how the screenshot is captured.
If "scrollTimeOut" is increased to 1000 ms or 2000 ms, the screen will be scrolled slowly.


  1. Replies
    1. Thanks Sandeep. Glad to hear that, keep visiting :)

  2. Hi Venkat,

    I am getting this below error .

    RuntimeException: org.openqa.selenium.WebDriverException: waiting for evaluate.js load failed

    do you an idea how to fix this?

    1. Hi Atul,
      aShot uses jQuery by default to find out the elements coordinates.But some drivers have problems with Javascript execution such as OperaDriver. In this case there is another way to find the WebElement's coordinates.

      new AShot()
      .coordsProvider(new WebDriverCoordsProvider()) //find coordinates with WebDriver API
      .takeScreenshot(webDriver, myWebElement);

  3. Thanks for providing the information . The articles in your blog helped me a lot for improving the knowledge on the subject. Also check my small collection on this at selenium Online Training Hyderabad blog

  4. How much amount of time we need to configure in the scroll timeout. Suppose we are giving 1 millisecond time so with that one millisecond it has to take screenshot since for every millisecond the scroll action, taking the screenshot of a webpage by that method happens in what amount of time.Is it lest than millisecond or greater than that time/

  5. If you've been an internet marketer for any amount of time you will eventually want to create some tutorials to help promote your website. screenshot guide

  6. How can I use it with python?


Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...