How to remove the rust_mozprofile used by Selenium

1.3k Views Asked by At

I have used selenium with python for a while and I recently discovered that my tmp dir is full of rust_mozprofile directories. How can I have them deleted on the fly?

I read in another post that I should use driver.quit() instead of driver.close() but I am already using driver.quit().

2

There are 2 best solutions below

0
undetected Selenium On

As per the discussion Is it Firefox or Geckodriver, which creates “rust_mozprofile” directory rust_mozprofile directories are created by GeckoDriver and Marionette while initiating a new Browsing Context i.e. Firefox Browser session.

Ideally, invoking quit() should delete them all. You can find a detailed discussion in Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?

As an alternate, you can use CCleaner tool to wipe off all the chores before and after the execution of your Test Suite.

0
OlivierOR On

you could do this by killing firefox session that had not been quit properly and then delete /tmp/ files created by the session.

pkill firefox
find /tmp -type f -delete