Selenium python web driver doesnt close

Viewed 2800

I call driver.quit() on test teardown, but the chromedriver process stays alive and doesn't shut down. So between executions sometimes Chrome doesn't open at all, and I need to manually shut down the processes. Someone familiar with this issue?

I'm using selenium 3.5

1 Answers

Change your code to below, to be double sure the process is not there after quit

import signal
import os
pid = driver.service.process.pid

driver.quit()
try:
    os.kill(int(pid), signal.SIGTERM)
    print("Killed chrome using process")
except ProcessLookupError as ex:
    pass
Related