Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed

后端 未结 14 1999
走了就别回头了
走了就别回头了 2020-11-21 23:05

Recently I switched computers and since then I can\'t launch chrome with selenium. I\'ve also tried Firefox but the browser instance just doesn\'t launch.

f         


        
14条回答
  •  日久生厌
    2020-11-21 23:25

    I encountered the exact problem running on docker container (in build environment). After ssh into the container, I tried running the test manually and still encountered

    (unknown error: DevToolsActivePort file doesn't exist)
         (The process started from chrome location /usr/bin/google-chrome-stable is 
          no longer running, so ChromeDriver is assuming that Chrome has crashed.)
    

    When I tried running chrome locally /usr/bin/google-chrome-stable, error message

    Running as root without --no-sandbox is not supported
    

    I checked my ChromeOptions and it was missing --no-sandbox, which is why it couldn't spawn chrome.

    capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
      chromeOptions: { args: %w(headless --no-sandbox disable-gpu window-size=1920,1080) }
    )
    

提交回复
热议问题