How to stop Selenium from creating temporary Firefox Profiles using Web Driver?
You can control how the Firefox driver chooses the profile. Set the webdriver.firefox.profile
property to the name of the profile you want to use. Most folks think this is a bad idea, because you'll inherit all the cookies, cache contents, etc. of the previous uses of the profile, but it's allowed if you really want to do it.
For example:
System.setProperty("webdriver.firefox.profile", "MySeleniumProfile");
WebDriver driver = new FirefoxDriver(...);
UPDATE - From Ranhiru
How I handled it for Java
FirefoxProfile profile = new FirefoxProfile(new File("D:\\Selenium Profile"));
WebDriver driver = new FirefoxDriver(profile);
Then I changed settings in Firefox to clear all cookies and cache when exiting. Look here on how to do it.
Why Selenium always create temporary Firefox Profiles using Web Driver?
The main reason that the Firefox driver uses a temporary profile is to support the use case of running multiple independent simultaneous instances of Firefox. At one time, when Firefox launched, it would drop a sentinel or lock file in the profile directory, and would detect that file if the user attempted to start a new instance of Firefox, preventing them from doing so. Whether or not Firefox still exhibits this behavior, the driver still has to work with some older versions of the browser, and has to account for it. The Selenium project's solution to that issue with WebDriver, when a user wants to use a specific profile, is to copy the contents of that profile to a new directory, and launch Firefox pointing to the copy.
It sounds like Mozilla's implementation does largely the same thing. I would guess it's for the same reason - to support the multiple-instance use case.
Related Topics
Finding Number of Cores in Java
Default Fetch Type for One-To-One, Many-To-One and One-To-Many in Hibernate
Spring Boot Jackson Date and Timestamp Format
Comparing Strings by Their Alphabetical Order
How to Restrict Jfilechooser to a Directory
Lambda Expression and Method Overloading Doubts
How to Set Oracle's Java as the Default Java in Ubuntu
Why Can't We Use '==' to Compare Two Float or Double Numbers
How to Check the Bitness of My Os Using Java? (J2Se, Not Os.Arch)
Best Way to Create Enum of Strings
How to Launch Ie Browser Using Selenium2 (Webdriver) with Java
Java 7 String - Substring Complexity
Calling Virtual Method in Base Class Constructor
@Transactional Method Called from Another Method Doesn't Obtain a Transaction