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

后端 未结 14 1762
走了就别回头了
走了就别回头了 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:24

    Assuming that you already downloaded chromeDriver, this error is also occurs when already multiple chrome tabs are open.

    If you close all tabs and run again, the error should clear up.

    0 讨论(0)
  • 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) }
    )
    
    0 讨论(0)
  • 2020-11-21 23:26

    I came across this error on linux environment. If not using headless then you will need

    from sys import platform
        if platform != 'win32':
            from pyvirtualdisplay import Display
            display = Display(visible=0, size=(800, 600))
            display.start()
    
    0 讨论(0)
  • 2020-11-21 23:27

    Make sure that both the chromedriver and google-chrome executable have execute permissions

    sudo chmod -x "/usr/bin/chromedriver"
    
    sudo chmod -x "/usr/bin/google-chrome"
    
    0 讨论(0)
  • 2020-11-21 23:28

    i faced the same problem but i solved it by moving the chromedriver to this path '/opt/google/chrome/'

    and this code works correctly

    from selenium.webdriver import Chrome
    driver = Chrome('/opt/google/chrome/chromedrive')
    driver.get('https://google.com')
    
    0 讨论(0)
  • 2020-11-21 23:29

    For RobotFramework

    I solved it! using --no-sandbox

    ${chrome_options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
    Call Method    ${chrome_options}    add_argument    test-type
    Call Method    ${chrome_options}    add_argument    --disable-extensions
    Call Method    ${chrome_options}    add_argument    --headless
    Call Method    ${chrome_options}    add_argument    --disable-gpu
    Call Method    ${chrome_options}    add_argument    --no-sandbox
    Create Webdriver    Chrome    chrome_options=${chrome_options}
    

    Instead of

    Open Browser    about:blank    headlesschrome
    Open Browser    about:blank    chrome
    
    0 讨论(0)
提交回复
热议问题