How can I capture full webpage screenshot using Selenium Webdriver?

0 votes
How can I capture full webpage screenshot using Selenium Webdriver?
Jul 29 in Selenium by Harbhajan
433 views

1 answer to this question.

0 votes

Hey Harbhajan, you can use Ashot() to capture full webpage screenshot in Python Selenium Webdriver. AShot() is a webdriver screenshot utility to capture entire page screenshot and is natively supported from Selenium 3 onwards.  You can download the jar files for AShot() from here: http://central.maven.org/maven2/ru/yandex/qatools/ashot/ashot/1.5.3/ashot-1.5.3.jar

Following code snippet shows how to use it for capturing full page screenshot:

import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;

public class EntirePageScreenshot {

    public static void main(String[] args) {
       
    WebDriver driver;      
       
            System.setProperty("webdriver.chrome.driver", ".\\Driver\\chromedriver.exe");
            driver=new ChromeDriver();
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
            driver.manage().window().maximize();
            driver.get("https://www.amazon.in");
           
//take screenshot of the entire page
            Screenshot screenshot=new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
            try {
                ImageIO.write(screenshot.getImage(),"PNG",new File("path of the file"));
            } catch (IOException e) {
                e.printStackTrace();
            }
           
            driver.quit();
          
        }
    }

answered Jul 29 by Anvi
• 13,960 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to capture screenshot of a webpage using Selenium Webdriver?

Hi Bindiya, you can use TakesScreenshot interface to capture the ...READ MORE

answered Jul 8 in Selenium by Abha
• 27,180 points
116 views
0 votes
1 answer

How can I verify Error Message on a webpage using Selenium Webdriver?

Hey Hansraj, to verify an error message ...READ MORE

answered Jul 18 in Selenium by Abha
• 27,180 points
280 views
0 votes
1 answer

How can I get meta-description of a webpage using Selenium Webdriver?

Hey Sonal, to get the meta-description of ...READ MORE

answered Jul 23 in Selenium by Abha
• 27,180 points
263 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8 in Selenium by Anvi
• 13,960 points
272 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
1,126 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,150 points
1,239 views
0 votes
1 answer

How can I capture screenshot of a webpage partially in Selenium?

Hey Tejasvi, you can capture screenshot of ...READ MORE

answered Jul 8 in Selenium by Anvi
• 13,960 points
56 views
0 votes
1 answer