By default, Geckodriver 0.30.0 copies existing FF profile to temporary files directory before launching a new instance of WebDriver
.
The code responsible for this is written in Rust
and is present in src/browser.rs
of geckodriver source, in line 60 - 70 as discussed in this thread:
let mut profile = match options.profile {
Some(x) => x,
None => Profile::new()?,
};
Iām able to permanently force Geckodriver 0.30.0
to use a specific FF Profile directly (w/o first making a copy of it) by modifying the above code to:
let path = std::path::Path::new("path-to-profile");
let mut profile = Profile::new_from_path(path)?;
However, this would only allow me to use a single profile in the entire application as the path_to_profile
is hard coded into above file.
I need to be able to launch hundreds of FF profiles throughout the lifecycle of my application and thus need to choose any existing profile at runtime using the following code structure:
File firefoxProfileFile= new File(path_to_profile_file);
FirefoxProfile firefoxProfile = new FirefoxProfile(firefoxProfileFile);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(firefoxProfile);
Using the code above it would be possible to dynamically select any existing FF profile at runtime, without first copying profile to temporary folder - but only if I can somehow pass the path to profile as an argument to above code.
How can this be done?