For many weeks now, I have been looking around and I have not seen anything regards to changing the location the Firefox Profile saves to.
I am using a specific Firefox profile, however, when the tests run the session is created in /tmp/. I would like the session to start up in a different location and save the files it uses in a location like: /var/tmp/. Is there any way to do this?
Note: This is not a question as to where I get the RemoteWebDriver to use a specific Firefox profile.
Edit: I am using Selenium 2.28 and Firefox 15.0.1
Look at FirefoxProfile:442
File profileDir = TemporaryFilesystem.getDefaultTmpFS()
.createTempDir("anonymous", "webdriver-profile");
copyModel(model, profileDir);
The TemporaryFilesystem
takes it's location from "java.io.tmpdir"
:, which usually points to system's temp directory. Santoshsarma's solution will work because of this line (but it will also move your OS temp directory).
private static File sysTemp = new File(System.getProperty("java.io.tmpdir"));
We can do more! Look at the public method setTemporaryDirectory
!
You can invoke this method just before instantiating your FirefoxDriver
and it should create it's profile copy at the location you specified.
Firefox uses the OS temp file location for storing temporary files
You need to change the location of the temp files in Windows in the control Panel if you want to use another location for temp files.
You can change the %TEMP% and %TMP% environment variables and make them point to a temp folder that you want to use.
Control Panel > System > Advanced > Environment variables
Refer : Firefox Support
来源:https://stackoverflow.com/questions/15124772/selenium-2-firefox-profile-change-location