是否可以使用 Selenium WebDriver 截屏?
(注意:不是Selenium 遥控器)
对的,这是可能的。以下示例使用 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"));