我试着用下面的代码截图:
public void screenShot() throws IOException, InterruptedException { //Take screenshot and save to file
File scr=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); //Destination where to store screenshot
File dest= new File("filepath/Visionscreenshot_"+timestamp()+".png"); // Copy the file to system ScreenshotPath
FileUtils.copyFile(scr, dest);
Thread.sleep(1200);
}
public String timestamp() {
return new SimpleDateFormat("YYYY-MM-DD HH-mm-ss").format(new Date());
} 我得到了一个错误:
Vision.Screenshot.screenShot1(Screenshot.java:37)中线程"main“java.lang.NullPointerException中的异常
发布于 2016-05-23 10:35:58
似乎你需要改变这一点:
File dest= new File("filepath/Visionscreenshot_"+timestamp()+".png");至
File dest= new File("<Some existing folder path from directory>" + "/Visionscreenshot_"+timestamp()+".png"); 注意:请注意文件分隔符。。
发布于 2016-08-01 09:57:42
试试这个:
File dest= new File("filepath\\Visionscreenshot_"+timestamp()+".png");并确保您的文件路径正确。
https://stackoverflow.com/questions/37388158
复制相似问题