Following this issue I encountered yesterday : selenium.common.exceptions.SessionNotCreatedException in Python Selenium using GeckoDriverManager, I would like to know if there was a way to delete at the end of a program execution the driver directory created by GeckoDriverManager.
Here's what I use to put in my codes :
import os, shutil
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager
service = FirefoxService(executable_path=GeckoDriverManager().install())
driver = webdriver.Firefox(service=service)
Every time this is executed, GeckoDriverManager creates a folder in my /tmp
directory called rust_mozprofile<random chars and digits>
. Is there any way or function to get the path to this folder, in order to delete it and its contents, for example using the code below?
def __cleanup(driverDirectoryPath):
if os.path.exists(driverDirectoryPath):
shutil.rmtree(driverDirectoryPath)