WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser

前端 未结 29 3367
旧巷少年郎
旧巷少年郎 2020-11-21 07:11

I am trying to launch chrome with an URL, the browser launches and it does nothing after that.

I am seeing the below error after 1 minute:

Unable to         


        
相关标签:
29条回答
  • 2020-11-21 07:21

    I ran into this problem on Ubuntu 20 with Python Selenium after first downloading the chromedriver separately and then using sudo apt install chromium-browser Even though they were the same version this kept happening.

    My fix was to use the provided chrome driver that came with the repo package located at

    /snap/bin/chromium.chromedriver

    driver = webdriver.Chrome(chrome_options=options, executable_path='/snap/bin/chromium.chromedriver')
    
    0 讨论(0)
  • 2020-11-21 07:21

    As stated in this other answer:

    This error message... implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

    Among the possible causes, I would like to mention the fact that, in case you are running an headless Chromium via Xvfb, you might need to export the DISPLAY variable: in my case, I had in place (as recommended) the --disable-dev-shm-usage and --no-sandbox options, everything was running fine, but in a new installation running the latest (at the time of writing) Ubuntu 18.04 this error started to occurr, and the only possible fix was to execute an export DISPLAY=":20" (having previously started Xvfb with Xvfb :20&).

    0 讨论(0)
  • 2020-11-21 07:21

    Old question but a similar issue nearly drove me to insanity so sharing my solution. None of the other suggestions fixed my issue.

    When I updated my Docker image Chrome installation from an old version to Chrome 86, I got this error. My setup was not identical but we were instantiating Chrome through a selenium webdriver.

    The solution was to pass the options as goog:chromeOptions hash instead of chromeOptions hash. I truly don't know if this was a Selenium, Chrome, Chromedriver, or some other update, but maybe some poor soul will find solace in this answer in the future.

    0 讨论(0)
  • 2020-11-21 07:22

    In my case, I was trying to create a runnable jar on Windows OS with chrome browser and want to run the same on headless mode in unix box with CentOs on it. And I was pointing my binary to a driver that I have downloaded and packaged with my suite. For me, this issue continue to occur irrespective of adding the below:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--headless");
    options.addArguments("--no-sandbox");
    System.setProperty("webdriver.chrome.args", "--disable-logging");
    System.setProperty("webdriver.chrome.silentOutput", "true");
    options.setBinary("/pointing/downloaded/driver/path/in/automationsuite");
    options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
    options.addArguments("disable-infobars"); // disabling infobars
    options.addArguments("--disable-extensions"); // disabling extensions
    options.addArguments("--disable-gpu"); // applicable to windows os only
    options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
    options.addArguments("window-size=1024,768"); // Bypass OS security model
    options.addArguments("--log-level=3"); // set log level
    options.addArguments("--silent");//
    options.setCapability("chrome.verbose", false); //disable logging
    driver = new ChromeDriver(options);
    

    Solution that I've tried and worked for me is, download the chrome and its tools on the host VM/Unix box, install and point the binary to this in the automation suite and bingo! It works :)

    Download command:

    wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
    

    Install command:

    sudo yum install -y ./google-chrome-stable_current_*.rpm
    

    Update suite with below binary path of google-chrome:

    options.setBinary("/opt/google/chrome/google-chrome");
    

    And.. it works!

    0 讨论(0)
  • 2020-11-21 07:22

    In my case, I'm in a Kubernetes environment where I cannot use the default TMPDIR because it will fill up the temp directory with garbage.

    So I was using this to use a different tmpdir:

    driver = new ChromeDriver(new ChromeDriverService.Builder()
                        .withEnvironment(ImmutableMap.of("TMPDIR", customTmpPath))
                        .build(), options);
    

    But now that I've upgraded everything to the latest, this no longer seems to work. I will need to find a new way to do this.

    0 讨论(0)
  • 2020-11-21 07:24

    I started seeing this problem on Monday 2018-06-04. Our tests run each weekday. It appears that the only thing that changed was the google-chrome version (which had been updated to current) JVM and Selenium were recent versions on Linux box ( Java 1.8.0_151, selenium 3.12.0, google-chrome 67.0.3396.62, and xvfb-run).
    Specifically adding the arguments "--no-sandbox" and "--disable-dev-shm-usage" stopped the error. I'll look into these issues to find more info about the effect, and other questions as in what triggered google-chrome to update.

    ChromeOptions options = new ChromeOptions();
            ...
            options.addArguments("--no-sandbox");
            options.addArguments("--disable-dev-shm-usage");
    
    0 讨论(0)
提交回复
热议问题