How to take full page screenshot using Selenium Webdriver + TestNG

23 views
Skip to first unread message

Raju Arelli

unread,
Sep 29, 2016, 6:45:10 AM9/29/16
to testng-users
Hi All,

Can anybody let me know how to take Full page screenshot in selenium webdriver in Firefox.
I am using TestNG Framework.

Below is the code I used @After Method-- But it's taking the screenshot of Viewport page only(page which we can see).

public void afterMethod(ITestResult result)
{
 

if(ITestResult.FAILURE==result.getStatus())
{
try
{

TakesScreenshot ts=(TakesScreenshot)driver;
 

File source=ts.getScreenshotAs(OutputType.FILE);
 
FileUtils.copyFile(source, new File("./Screenshots/"+result.getName()+".png"));
 
System.out.println("Screenshot taken");
}
catch (Exception e)
{
 
System.out.println("Exception while taking screenshot "+e.getMessage());
}
 
 }
Thanks,Raju
Reply all
Reply to author
Forward
0 new messages