When I use below code, Its creating \scrshot\vb\uv even though \scrshot\vb not exist in D drive.
takeScreenshot("D:\\scrshot\\vb\\uv", "s.png");
public void takeScreenshot(String fileDir,String fileName)
{
File directory=new File(fileDir);
if(!directory.exists())
directory.mkdir();
File file=((TakesScreenshot)ddr).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(file,new File(directory.getAbsolutePath()+File.separator+fileName));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
If my understanding is correct mkdir() would not create parent folder if it does not exist. but here its creating \scrshot\vb\ under D drive. this thread for reference.