Unable to capture full webpage screenshot using selenium web | Selenium Forum
M
Posted on 03/10/2016
[quote:23up7yrp]Hi All,

I have written the below code to capture the screen shot of a whole webpage.

But I'm able to capture only the partial/visible part of the webpage displayed not the whole webpage. Please suggest.

Im Using:

Selenium WebDriver Version: 3.0.0-beta3

Firefox Version: 49.0.1

OS: Win10[/quote:23up7yrp]

[code:23up7yrp]import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ScreenShot {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver","C:\\Eclipse\\Drivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.flipkart.com/");
File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File("C:\\Users\\Vishvambruth JT\\Desktop\\FlipKart.jpg"));
}
}[/code:23up7yrp]

M
Replied on 03/10/2016

you're able to capture all the visible part.


M
Replied on 04/10/2016

I need to capture the whole webpage not only the visible part. Is it possible?


M
Replied on 04/10/2016

you can scroll and capture again.


M
Replied on 05/10/2016

Could you please alter my code so that my code can scroll and capture the entire webpage.


M
Replied on 05/10/2016

it is explained in the videos how to scroll a webpage.

and after that capture again.
using this code
[code:1rabqr4g]File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File("C:\\Users\\Vishvambruth JT\\Desktop\\FlipKart.jpg")); [/code:1rabqr4g]


M
Replied on 05/10/2016

Is it under?

Training Video - 13
Selenium Webdriver - 3


M
Replied on 06/10/2016

look at this q/a to scroll

http://stackoverflow.com/questions/12293158/page-scroll-up-or-down-in-selenium-webdriver-selenium-2-using-java