I’m facing an issue in the folder creation. Please find my requirement below
Each time you run the tests, a new folder is created with the time stamp.
Under the time stamp folder, another folder should get created. For example,
Under this sub folder new folders should get created one beside another and no duplicates are allowed.
Try - 1
public static File outputFile;
public static void screenshot_TimeStamp_Language_Folder(String language){
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
outputFile = new File(timeStamp+"./L"+"_"+language);
outputFile.mkdir();
System.out.println(outputFile);
}
public static void screenshot_TestCaseFolder(String testCaseFolderName){
String st = outputFile.getAbsolutePath();
outputFile = new File(st+"./xyz_"+testCaseFolderName);
outputFile.mkdir();
System.out.println(outputFile);
}
public static void CaptureScreen(AppiumDriver driver, String imageFileName)
{
File scrFile = driver.getScreenshotAs(OutputType.FILE);
//String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
String path = outputFile.getAbsolutePath();
System.out.println(path);
File outputFile = new File(path + "/" + imageFileName +".jpg");
try {
FileUtils.copyFile(scrFile, outputFile);
}
catch (IOException ex) {
System.out.println(Level.SEVERE + " Failed to save screen shot to " + outputFile);
}
}
But I’m failing in the third step (i,e instead of creating sub folders one beside the another its creating folder inside the folder if you are calling screenshot_TestCaseFolder() method for more than one time in the same execution)
EX: public void test(){ screenshot_TestCaseFolder(); screenshot_TestCaseFolder(); screenshot_TestCaseFolder(); }
Please help me in resolving this issue
Thanks in advance