美文网首页
关于python:Selenium:WebDriverExcep

关于python:Selenium:WebDriverExcep

作者: 一位先生_ | 来源:发表于2023-08-09 13:19 被阅读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/

    相关文章

      网友评论

          本文标题:关于python:Selenium:WebDriverExcep

          本文链接:https://www.haomeiwen.com/subject/besmpdtx.html