How to change temporary file system path selenium 3

1.1k Views Asked by At

I'm trying to change the temporary file system path of Selenium 3.x. because I want to place the temporary firefox profiles (moz_profile) on a ram disk

In Selenium 2.52 I was able to change the directory with the following code:

 TemporaryFilesystem.setTemporaryDirectory(TEMP_DIRECTORY);

After doing that, Selenium creates "anonymous" directories for each browser session.

Selenium 3.x ignores the configured temporary directory.

Also that didn't work:

System.setProperty("java.io.tmpdir", TEMP_DIRECTORY)

What is getting wrong here? Thanks for your help!

File temporaryFileDirectory = new File("/Users/sebsch/Desktop/temp");
        if (!temporaryFileDirectory.exists()) {
            temporaryFileDirectory.mkdirs();
        }
        System.setProperty("java.io.tmpdir", temporaryFileDirectory.getAbsolutePath());
        TemporaryFilesystem.setTemporaryDirectory(temporaryFileDirectory);

        System.setProperty(GECKO_DRIVER_EXE_PROPERTY, file.getAbsolutePath());

        System.out.println("Starting selenium test!");
        WebDriver webDriver = null;
        try {
            FirefoxOptions firefoxOptions = new FirefoxOptions();

            FirefoxProfile profile = new FirefoxProfile();
            firefoxOptions.setProfile(profile);
            firefoxOptions.setLogLevel(FirefoxDriverLogLevel.TRACE);
            firefoxOptions.setCapability("marionette", true);
            firefoxOptions.setCapability("acceptInsecureCerts", true);


            webDriver = new FirefoxDriver(firefoxOptions);
0

There are 0 best solutions below