![](/img/trans.png)
[英]Capturing full screen shot of webpage content using selenium 3 webdriver
[英]How to capture the screen shot of a webpage using selenium webdriver?
我正在尝试使用下面提到的脚本来捕获网页的屏幕截图:
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("D:\\screenshot.jpg"));
我得到以下方法类型的copyFile未定义。 除了导入java.io.File之外,我是否缺少任何软件包? 并导入com.sun.jna.platform.FileUtils;。
我使用的方法与您相同,对我来说效果很好。
一个猜测:检查项目中的导入:
import org.apache.commons.io.FileUtils;
那可能导致您得到的错误...
顺便说一句,这是我的方法,可以正常工作:
public void takeScreenshot(String nameOfOutputFileIncludingExtension) throws IOException {
File scrFile = new File("");
scrFile = ((TakesScreenshot)getDriver().getScreenshotAs(OutputType.FILE);
File destination = new File("target/surefire-reports/" + nameOfOutputFileIncludingExtension);
System.out.println("Screenshot stored at:" + destination.getAbsolutePath());
FileUtils.copyFile(scrFile, destination);
}
导入应为: import org.apache.commons.io.FileUtils;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.