1

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?

S.O.S
  • 848
  • 10
  • 30
  • Just create a contructor with `path_to_profile_file` as arg. `WebDriver startGeckoDriver(String path_to_profile_file) {WebDriver driver = ...; return driver; }` and call `WebDriver driver1 = startGeckoDriver(path1); WebDriver driver2 = startGeckoDriver(path2);` – pburgr Apr 11 '22 at 12:31
  • @pburgr This won't create a temp folder first? I think it does.. – S.O.S Apr 11 '22 at 15:54

0 Answers0