我正在使用 selenium,我编写了一个截取屏幕截图并将其保存在指定文件夹中的方法,但它一直抛出异常。为什么? 这是我的代码:
public void takeScreenshot(WebDriver driver) throws IOException{
Date date = new Date();
String fileName = new SimpleDateFormat("MM-dd-yy_HH:mm:ss").format(date).concat(".jpeg");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
File destFile = new File(SCREENSHOTS.toString().concat(fileName));
FileUtils.copyFile(scrFile, destFile);
}
我遇到以下异常:
Exception in thread "main" java.io.FileNotFoundException: C:\Screenshots\09-13-15_02:10:52.jpeg (The filename, directory name, or volume label syntax is incorrect)
最佳答案
关于java - 当我尝试用 Java 保存屏幕截图时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32547253/