linux下无法启动webdriver问题

linux下无法启动webdriver问题:

查看是否有足够多的webdriver进程:

ps -ef | grep chromedriver

kill -9 `ps -ef |grep chromedriver | awk '{print $2}' `

再次启动就ok,程序中一定要保证webdriver执行driver.quit(),不然长期积累会导致服务器越来越卡!

ChromeDriver是轻量级的服务,在单任务或不需要频繁启动浏览器的情况下,使用driver.quit()关闭浏览器,可以正常结束ChromeDriver进程。若在一个比较大的 测试套件中频繁的启动关闭,会增加一个比较明显的延时导致浏览器进程不被关闭的情况发生,为了避免这一状况我们可以通过ChromeDriverService来控制ChromeDriver进程的生死,达到用完就关闭的效果避免进程占用情况出现(Running the  server in a child process)

from selenium.webdriver.chrome.service import Service

service = Service(executable_path='/usr/bin/chromedriver', port=9080)
option = webdriver.ChromeOptions()
driver = webdriver.Remote(command_executor=service.service_url, options=option)
dotask........
driver.quit()  




所有任务完成的时候:  
  service.stop()
 
如果使用supervisor管理进程,一定要配置,退出子进程:

killasgroup=true
stopasgroup=true



driver service:

https://www.cnblogs.com/wmhuang/p/8011815.html
  

参见:

https://www.codeleading.com/article/87851431040/

原文地址:https://www.cnblogs.com/tianboblog/p/12031341.html