0

I'm trying to launch a specific profile in Selenium v4 and Java using the following code:

System.setProperty("webdriver.gecko.driver", path_to_geckdriver);
File firefoxProfileFile = new File(path_to_file);
FirefoxProfile firefoxProfile = new FirefoxProfile(firefoxProfileFile);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(firefoxProfile);

It took 411 seconds (almost 7 minutes) to load said profile.

When debugging above, I noticed that the folder: \MyProfile\cache2\entries\ has 28,000 items in it totaling 1+ GB of data. I deleted all of the items and ran above code again and this time it took (only?) 69 seconds to load said profile.

My question is:

  1. What process is populating this folder with so many garbage entries? How can I prevent FF from populating \MyProfile\cache2\entries\ with so many entries in the future?

  2. While the load time is now much better, is 60 second load time really the fastest I can achieve?

P.S: I am not creating a temporary FF profile, rather I'm loading existing profile from file.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
S.O.S
  • 848
  • 10
  • 30

1 Answers1

0

When you initiate a Browsing Context using Selenium from an existing FirefoxProfile the following settings/configurations:

  • browser settings
  • Extensions
  • Bookmarks
  • Apps
  • Saved Passwords
  • Browsing History

are copied from the actual profile directory into a temporary rust_mozprofile as follows:

1521447102321   mozrunner::runner   INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\SOS\\AppData\\Local\\Temp\\rust_mozprofile.2oSwrQwQoby9"

Naturally, the more the settings/configurations to be copied the more time is required for the I/O to complete.

You can find a relevant detailed discussion in webdriver.FirefoxProfile(): Is it possible to use a profile without making a copy of it?

However, to reduce the amount of the leftovers from the executions you should always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Appreciate the response. However, two things still remain unclear to me **1)** After deleting cache entries the entire FF folder is around 200 MB. It doesn't take anything close to 60 seconds to copy 200 MB of data on my PC (maybe 3-5 seconds max) **2)** I still don't understand what process is generating so much garbage in `\MyProfile\cache2\entries\`. Is this normal? It's not like I'm browsing thousands of websites with this profile that the cache should be populated like this. – S.O.S Apr 10 '22 at 05:47
  • The amount of the cache may vary between the type of Firefox browser (Mozilla Firefox, Firefox Nightly, Firefox Development, ESR, etc) and the features and functionalities added/removed. – undetected Selenium Apr 10 '22 at 06:33