selenium-shutterbug

How to take screenshot with Selenium WebDriver

回眸只為那壹抹淺笑 提交于 2019-11-25 23:57:56
问题 Does anyone know if it\'s possible to take a screenshot using Selenium WebDriver? (Note: Not Selenium RC) 回答1: Java 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")); 回答2: Python Each WebDriver