简体   繁体   English

Selenium python web驱动程序不关闭

[英]Selenium python web driver doesnt close

I call driver.quit() on test teardown, but the chromedriver process stays alive and doesn't shut down. 我在测试拆卸时调用driver.quit() ,但是chromedriver进程保持活动状态并且不会关闭。 So between executions sometimes Chrome doesn't open at all, and I need to manually shut down the processes. 因此,执行之间有时Chrome根本不会打开,我需要手动关闭进程。 Someone familiar with this issue? 有人熟悉这个问题吗?

I'm using selenium 3.5 我正在使用硒3.5

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM