Is it Firefox or Geckodriver, which creates "rust_mozprofile" directory
Asked Answered
H

4

12

Whenever we invoke Firefox, under '/tmp' directory rust_mozprofile directories are getting created. As Firefox internally calls Geckodriver we are not sure whether Firefox or Geckodriver is creating rust_mozprofile directory.

I do want to know whether Geckodriver or Firefox because, my '/tmp' directory is having less memory.

So the question is I really want to modify the path of creating directories for rust_mozprofile.

I am using below technologies,

  • Selenium - 3.3.0
  • Firefox - 52.2.0
  • Geckodriver - 13

Please give us some suggestion, if there is any.

Horick answered 7/9, 2017 at 5:25 Comment(0)
M
6

If you have a closer look at the geckodriver v0.18.0 logs closely you will observe the very first occurrence of rust_mozprofile occurs in the following line:

1504762617094   Marionette  CONFIG  Matched capabilities: {"browserName":"firefox","browserVersion":"56.0","platformName":"windows_nt","platformVersion":"6.2","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":5848,"moz:profile":"C:\\Users\\AtechM_03\\AppData\\Local\\Temp\\rust_mozprofile.OfFuR9ogm33d","moz:accessibilityChecks":false,"moz:headless":false}

This log clearly indicates that is being configured with:

"moz:profile":"C:\\Users\\AtechM_03\\AppData\\Local\\Temp\\rust_mozprofile.OfFuR9ogm33d" 

And this configuration is done by the WebDriver instance i.e. the GeckoDriver.

It's the GeckoDriver which internally configures the Marionette which in-turn initiates the Mozilla Firefox Browser.

IMO, this workflow is in practice since we migrated from the Legacy Firefox to Marionette based Firefox. Hence the same must be the case with Geckodriver - 13 as well.


Update:

GeckoDriver as an application/exe file: enter image description here

Modie answered 7/9, 2017 at 6:24 Comment(8)
Your answer gives us some clarity now. After this the problematic question is whether we can change the rust_mozprofile path. If it is there, then can you let us know where I can do that. Thank you.Horick
@abc Yes, you can do that pretty easily by changing the location in the default configuration & build the customized geckodriver at your end.Modie
Ok. But as you see when we are using windows, geckodriver is a jar file which can be edited. But in linux environment we have geckodriver as executable file. Is there anyone where we can edit that file.Horick
@abc Even on Windows geckodriver is a application/exe file. Updated image in the Answer.Modie
So do you have any insight on modifying the default configuration ?Horick
@abc If use geckodriver in default configuration, geckodriver will keep on scooping a new rust_mozprofile on each run. Probably(unsure), to get rid of it, you may consider creating a separate Firefox Profile and use the same Firefox Profile in your Test Execution.Modie
Let us continue this discussion in chat.Horick
How would you find "the location in the default configuration"? I opened up the source code of geckodriver in pycharm and went through every file. Never found any path that contained 'Temp' or 'rust' etc.Lymphoma
A
1

You can set the location with the TMPDIR envvar. It's also useful to set both TMP and TEMP for other programs.

Abana answered 8/3, 2019 at 13:30 Comment(0)
M
0

A solution is to use driver.quit() this closes all browsers and takes care of the profiles

Another solution is to add a custom profile

fp = webdriver.FirefoxProfile('specify location to profile .default') 
driver = webdriver.Firefox(firefox_profile=fp)
Mountie answered 16/4, 2018 at 20:15 Comment(4)
custom profile isn't a solution at all, since all those directories are still created under the /tmp anyway. actually, in my case it creates even two identical directories with the same copy of the specified profile: /tmp/rust_mozprofileXXX and /tmp/tmpXXX (on Linux), so I think there is no way to specify a custom path that will be used to create a new profile directory (from scratch or from existing profile, doesn't matter in this case).Duckbill
even more - we can't get the actual path to this rust_mozprofile directory from Selenium, so we can only rely on driver.quit() as you mentioned (and in case of any unhandled error - we still have rust_mozprofile coffins under the system /tmpDuckbill
probably we can parse the geckodriver's log at the run time to get the path to rust_mozprofile directory, but it sounds like a super dirty hack to meDuckbill
@Duckbill Actually we can get the actual path even before using the driver, with fp.path. However, it is still a copy and not the specified profile path.Attract
P
0

I had a similar problem and I solved it by changing the Environment settings in Windows. Meaning that I changed the directory for the TMP and TEMP files, and after a reboot, the rust_mozprofile folder was generated where I wanted it.

This is the source I used: https://www.toolsqa.com/selenium-webdriver/how-to-use-geckodriver/ Specifically the "Set property in Environment Variables:-" section.

Sadly this will effect all Software that saves files to those folders. (In my case that is what I wanted though.) If there is a way to make only the rust_mozprofile folder be created in a specific directory through the program, I would love to learn more.

Psychophysics answered 3/3, 2019 at 9:18 Comment(1)
That link is broken now. Is there a new version?Sharpeyed

© 2022 - 2024 — McMap. All rights reserved.