While running selenium grid tests from my Windows Hub on my Mac Node, I cannot create a directory aka folder on the Mac Node. I think my code is correct. It worked for the Windows Node. I am suspecting I didn't set up the permissions to create the folder correctly on the Mac. Can someone tell me where would I get the correct permissions on the Mac to allow Selenium WebDriver Selenium Grid to create a folder on the Mac?

I tried getting info on the screencaptures folder and assigning read and write access to the logged in mac user that is also an admin and applying it to the enclosed items. I also did that to the root directory too. However, when I ran the tests it still could not create the directory aka folder on the Mac. I also tried setting File Sharing between my Windows and Mac computer, but that did not help either.

Has anyone created a folder on the Mac via Selenium WebDriver Java code? What setup steps did you have to take on the Mac to get it to work correctly?


java.io.IOException: Destination '\Users\xyz\screencapture
\Pg_WatchTV_Test14x01x19.322' directory cannot be created
at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1085)
at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1038)
at otherClasses.ScreenshotURL_MAC.takescreenshotURL

        File scrFile =    
        if (scrFile != null)
            System.out.println("Just taken screenshot.");

        //Foldername is "/Users/xyz/screencaptures/error1"
        System.out.println("foldername: "+foldername);
        file_name = foldername + "/" + errorname + dateNow + ".jpg"; //Mac
        System.out.println("file_name: "+file_name);

        File directory2 = new File("/Users/xyz/screencaptures");
        boolean successful2 = directory2.canWrite();
           if (successful2)
               System.out.println("Can write");
               System.out.println("Can not write");

        directory = new File(foldername);
        System.out.println("Directory is: "+directory);
               boolean successful = directory.mkdirs();
                if (successful)
                  // creating the directory succeeded
                  System.out.println("Directory was created successfully.");
                  // creating the directory failed
                  System.out.println("Failed trying to create the
            System.out.println("Directory exists");

        FileUtils.copyFile(scrFile, new File(file_name));

1 Answer 1


A Platform independent way to create folder would be something like:-

File rootDir = File.listRoots()[0];
File dir = new File(new File(new File(new File(rootDir, "Users"), "xyz"), "screencapture"), "new folder you want to create");
if (!dir.exists()){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.