I use Selenium to perform automation. However, if I repeat automation, I have a lot of chromedrivers.
I want to solve this problem. Can't you just run one chromedriver?
As per the screenshot you have provided there seems to be presence of a couple of Zombie ChromeDriver process within your system.
Answering straight, you can't work with initiating just one ChromeDriver process while repeat automation as you can not reconnect to the previous browsing session. You can find a detailed discussion in How can I reconnect to the browser opened by webdriver with selenium?
You code trials would have given us more insights why the ChromeDriver processes are not getting cleaned up. As per best practices always invoke driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully as follows:
driver.quit() // Python
//or
driver.quit(); // Java
//
driver.Quit(); // DotNet
You can find a detailed discussion in PhantomJS web driver stays in memory
Incase the ChromeDriver processes are still not destroyed and removed you may require to kill the processes from tasklist. You can find a detailed discussion in Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?
Python Solution(Cross Platform):
import os
import psutil
PROCNAME = "geckodriver" # or chromedriver or IEDriverServer
for proc in psutil.process_iter():
# check whether the process name matches
if proc.name() == PROCNAME:
proc.kill()