Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

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

1 Answer

0 votes
by (62.9k points)

Yes, it is possible. The following example is in Java:

WebDriver driver = new FirefoxDriver();

driver.get("http://www.google.com/");

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

// Now you can do whatever you need to do with it, for example copy somewhere

FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...