LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

How to take screenshot with Selenium WebDriver

Does anyone know if it's possible to take a screenshot using Selenium WebDriver? (Note: Not Selenium RC)

Up Vote Down Vote 0 Votes
Posted one month ago

Answers


Its possible to take a screenshot using Selenium WebDriver.

**Syntax to capture and save the screenshot. **

File screenshotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

**Syntax to store it in our local drive **

FileUtils.copyFile(screenshotFile, new File("filename_with_path"));

**For example: **

FileUtils.copyFile(screenshotFile, new FIle("D:\\screenshot.png"));

Check this space for complete program on capture a screenshot using Selenium WebDriver.

Up Vote Down Vote 0 Votes
Posted one month ago