> For the complete documentation index, see [llms.txt](https://tvn.gitbook.io/selenium-java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tvn.gitbook.io/selenium-java/examples/5.15.-capture-screenshot.md).

# 5.15. Capture Screenshot

```java
@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);
    }
```
