【发布时间】:2014-04-28 10:29:45
【问题描述】:
我目前正在研究 Selenium WebDriver、Java 和 TestNG 框架。
我用 Java 编写的代码。
如果我的 Java 代码是布尔值,我如何截取屏幕截图?
例子:
public boolean test() throws Exception {
// Some implementation
}
我尝试了这一步,但它显示错误:
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"));
copyFile 的这一行中的错误显示为The method copyFile(File, File) is undefined for the type FileUtils:
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
【问题讨论】:
-
check this link。在发布此问题之前,您真的进行过任何搜索吗?
-
这是Selenium FAQ中投票最高的问题。
-
“我的 Java 代码是布尔值”是什么意思?
标签: java selenium selenium-webdriver