小编典典

如何使用Selenium WebDriver截屏

selenium

有谁知道是否可以使用Selenium WebDriver截屏?(注:不是seleniumRC)


阅读 278

收藏
2020-06-26

共1个答案

小编典典

Java

是的,有可能。以下示例是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"));
2020-06-26