-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Labels
C-pyPython BindingsPython BindingsJ-awaiting answerQuestion asked of user; a reply moves it to triage againQuestion asked of user; a reply moves it to triage again
Description
🐛 Bug Report
When open Selenium Firefox with a profile folder path, calling .quit() on the driver does not clean up the temporary file. Overtime, it overwhelms the docker/ virtual machine disk
To Reproduce
def create_selenium_webdriver(profile_path):
"""
profile_path: str
"""
if not profile_path.exists():
sys.exit("Could not find profile folder")
driver = webdriver.Firefox(profile_path)
driver.set_page_load_timeout(30)
driver.maximize_window()
return driver
driver = utils.create_selenium_webdriver(profile_name)
driver.quit()\tmp folders still contains temporary files created by selenium
Expected behavior
\tmp folder should be cleared.
Environment
OS: Ubuntu 18.04
Browser: Firefox
Browser version: 80
Browser Driver version: GeckoDriver 0.27
Language Bindings version: selenium 3.141.0
Selenium Grid version (if applicable): inapplicable
Investigation
In selenium/webdriver/firefox/webdriver.py:
def quit(self):
"""Quits the driver and close every associated window."""
try:
RemoteWebDriver.quit(self)
except Exception:
# We don't care about the message because something probably has gone wrong
pass
if self.w3c:
self.service.stop()
else:
self.binary.kill()
if self.profile is not None:
try:
shutil.rmtree(self.profile.path)
if self.profile.tempfolder is not None:
shutil.rmtree(self.profile.tempfolder)
except Exception as e:
print(str(e))self.profile is a PosixPath if profile_path is an path-like object , which doesn't have.path attribute. This trigger an exception and the line:
if self.profile.tempfolder is not None:
shutil.rmtree(self.profile.tempfolder)was never executed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-pyPython BindingsPython BindingsJ-awaiting answerQuestion asked of user; a reply moves it to triage againQuestion asked of user; a reply moves it to triage again