以下に示すように、2つのメソッドを作成しています。
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 スクリプトでスクリーンショットを取得する方法を使用すると、フォルダーが作成され、現在の日付と時刻でスクリーンショットを取得したいので、どこが間違っているかを指摘してください。