How to capture screenshot in selenium webdriver?
Question
How to capture screenshot in selenium webdriver?
Answer
Below code can be used to capture screenshot
public static void captureScreenMethod() throws Exception{
System.setProperty(""webdriver.chrome.driver"",""D://Selenium //Drivers//chromedriver.exe"");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get(""https://www.codeGreen.com"");
File screenshotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile, new File(""D:\SoftwareTestingMaterial.png""));
driver.close();
driver.quit();
}