5.15. Capture Screenshot
@Test
void captureScreenshot() throws IOException {
WebDriver driver = new ChromeDriver();
driver.get("https://www.selenium.dev/");
TakesScreenshot scrShot =((TakesScreenshot)driver);
File srcFile=scrShot.getScreenshotAs(OutputType.FILE);
File destFile=new File("target/selenium.png");
FileUtils.copyFile(srcFile, destFile);
}
Last updated
Was this helpful?