********************CODE*******************
package aveditor;
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.io.FileHandler;
public class TakeScreenShotInJava{
public static void main(String []args)
{
WebDriver driver;
System.setProperty("webdriver.chrome.driver", ".\\ChromeDriverPath\\chromedriver.exe");
driver=new ChromeDriver();
driver.get("http://www.google.com/");
driver.manage().window().maximize(); //Maximize the Window after Opening the Links
// Taking ScreenShot after opening the URL
TakesScreenshot screenShot=((TakesScreenshot)driver);
File scrshot=screenShot.getScreenshotAs(OutputType.FILE);
// Saving the File to the mentioned Folder
try {
FileHandler.copy(scrshot, new File(".\\shots\\Screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
}
driver.quit();
}
}
package aveditor;
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.io.FileHandler;
public class TakeScreenShotInJava{
public static void main(String []args)
{
WebDriver driver;
System.setProperty("webdriver.chrome.driver", ".\\ChromeDriverPath\\chromedriver.exe");
driver=new ChromeDriver();
driver.get("http://www.google.com/");
driver.manage().window().maximize(); //Maximize the Window after Opening the Links
// Taking ScreenShot after opening the URL
TakesScreenshot screenShot=((TakesScreenshot)driver);
File scrshot=screenShot.getScreenshotAs(OutputType.FILE);
// Saving the File to the mentioned Folder
try {
FileHandler.copy(scrshot, new File(".\\shots\\Screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
}
driver.quit();
}
}