java如何保存从webdriver截图并保存在项目文件夹中?
public class ScreenCapture {
PartyBase partybase = new PartyBase() ;
public void getscreenshot(String testname)
{
Date date = new Date() ;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss") ;
File scrFile = ((TakesScreenshot)PartyBase.driver).getScreenshotAs(OutputType.FILE);
//The below method will save the screen shot in d drive with name "screenshot.png"
try {
FileUtils.copyFile(scrFile, new File("BaseApp\\BaseApp\\screenshots\\screenshot_"+testname+"_"+dateFormat.format(date)+".png"));
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("e::::::::::"+e);
}
}
}
我正在从selenium webdriver中截图,希望将它们保存在我的项目截图文件夹中,如图所示。我不能这样做,请帮助我在代码中需要做什么更改
共 (0) 个答案