public static void getScreenshot(WebDriver driver){
File screenshot=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String currentLocation=
System.getProperty("user.dir")+"/src/main/java/screenshots/";
//but you can put your location
try {
FileUtils.copyFile(screenshot,
new File(currentLocation + System.currentTimeMillis() + ".png"));
}catch (IOException e){
System.out.println("The screenshot was not taken");
e.printStackTrace();
}
}
1条答案
按热度按时间8tntrjer1#
我用这个方法来截图
字符串