关于python:Selenium:WebDriverExcep

2023-08-09  本文已影响0人  一位先生_

问题:
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /opt/google/chrome/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Python解决方案:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location ="C:\\\\path\\\\to\\\\chrome.exe"    #chrome binary location specified here
options.add_argument("--start-maximized") #open Browser in maximized mode
options.add_argument("--no-sandbox") #bypass OS security model
options.add_argument("--disable-dev-shm-usage") #overcome limited resource problems
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'C:\\path\\to\\chromedriver.exe')
driver.get('http://google.com/')

参考: https://www.codenong.com/53073411/

上一篇下一篇

猜你喜欢

热点阅读