import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
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;
import org.testng.annotations.Test;
//import com.thoughtworks.selenium.Selenium;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class FullPageScreenShout {
public WebDriver driver;
// public Selenium selenium;
public void FullPageScreenshot() throws Exception
{
DateFormat dateFormat = new SimpleDateFormat("yyyy_MMM_dd HH_mm_ss");
Date date = new Date();
String time=dateFormat.format(date);
System.out.println(time);
File f = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(f, new File("/home/chinna/Desktop/TechLearn"+time+".png"));
// Linux machine path
// FileUtils.copyFile(f, new File("E:\\Workspace\\Techlearn"+time+".png"));
// for windows matchine path
}
@Test
// Print Full Screenshot
public void TakeScreenShot() throws Exception
{ driver.get("http://seleniumsubbu.blogspot.in/");
FullPageScreenshot();
}
@BeforeTest
public void beforeTest()
{
driver= new FirefoxDriver();
driver.manage().window().maximize();
}
@AfterTest
public void afterTest()
{
}
}
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
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;
import org.testng.annotations.Test;
//import com.thoughtworks.selenium.Selenium;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class FullPageScreenShout {
public WebDriver driver;
// public Selenium selenium;
public void FullPageScreenshot() throws Exception
{
DateFormat dateFormat = new SimpleDateFormat("yyyy_MMM_dd HH_mm_ss");
Date date = new Date();
String time=dateFormat.format(date);
System.out.println(time);
File f = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(f, new File("/home/chinna/Desktop/TechLearn"+time+".png"));
// Linux machine path
// FileUtils.copyFile(f, new File("E:\\Workspace\\Techlearn"+time+".png"));
// for windows matchine path
}
@Test
// Print Full Screenshot
public void TakeScreenShot() throws Exception
{ driver.get("http://seleniumsubbu.blogspot.in/");
FullPageScreenshot();
}
@BeforeTest
public void beforeTest()
{
driver= new FirefoxDriver();
driver.manage().window().maximize();
}
@AfterTest
public void afterTest()
{
}
}