에 저장됩니다 :다음은 현재 날짜와 시간
public static String currentDateTime() {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
String cal1 = dateFormat.format(cal.getTime());
return cal1;
}
public static void screenShot(WebDriver driver) throws IOException {
File scrnsht = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String datetime = GenericFunctions.currentDateTime();
FileUtils.copyFile(scrnsht, new File("D:\\Screenshot1.png"+datetime));
}
그러나, 나는 다음 내 WebDriver 스크립트에서 폴더를 테이크 스크린 샷 방법을 사용할 때 만들었습니다. 현재 날짜와 시간으로 스크린 샷을 찍고 싶습니다. 제게 잘못 생각한 부분을 알려주십시오.
같은 존재한다면 대신 1을 사용하면 당신은 루프를 사용하거나 할 수 있습니다 것이 좋습니다 수의 쓸모없는 코드이므로 제거하고 싶을 수도 있습니다. – aimbire
파일이 png가되지 않습니까? 나는 "D : \\ Screenshot1-"+ datetime + ".png"'가 더 적절하다고 제안 할 것이다. – Nashibukasan
아니요. 나에게 적합하지 않습니다. 새 코드를 제공하면 "스크린 샷을 찍을 때 현재 날짜와 시간을 절약 할 것입니다." – user2181837