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

前端 未结 29 3366
旧巷少年郎
旧巷少年郎 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:36

    I had the same issue, but in my case chrome previously was installed in user temp folder, after that was reinstalled to Program files. So any of solution provided here was not help me. But if provide path to chrome.exe all works:

    chromeOptions.setBinary("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
    

    I hope this helps someone =)

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

    Since this is the most active message for this type of error, I wanted to mention my solution (after spending hours to fix this).

    On Ubuntu 18.04, using Chrome 70 and Chromedriver 2.44, and Python3 I kept getting the same DevToolsActivePort error, even when I disabled all options listed above. The chromedriver log file as well as ps showed that the chromedriver I set in chrome_options.binary_location was running, but it always gave DevToolsActivePort error. When I removed chrome_options.binary_location='....' and add it to webdriver creation, I get it working fine. webdriver.Chrome('/path to ... /chromedriver',chrome_options=chrome_options)

    Thanks everybody for your comments that make me understand and resolve the issue.

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

    update capabilities in conf.js as

    exports.config = {
      seleniumAddress: 'http://localhost:4444/wd/hub',
      specs: ['todo-spec.js'],
      capabilities: {
        browserName: 'chrome',
        chromeOptions: {
          args: ['--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage']
        }
      },
    
    };
    
    0 讨论(0)
  • 2020-11-21 07:38

    I ran into same issue, i am using UBUNTU, PYTHON and OPERA browser. in my case the problem was originated because i had an outdated version of operadriver.

    Solution: 1. Make sure you install latest opera browser version ( do not use opera beta or opera developer), for that go to the official opera site and download from there the latest opera_stable version.

    1. Install latest opera driver (if you already have an opera driver install, you have to remove it first use sudo rm ...)

    wget https://github.com/operasoftware/operachromiumdriver/releases/download/v.80.0.3987.100/operadriver_linux64.zip

       unzip operadriver_linux64.zip
       sudo mv operadriver /usr/bin/operadriver
       sudo chown root:root /usr/bin/operadriver
       sudo chmod +x /usr/bin/operadriver
    

    in my case latest was 80.0.3987 as you can see

    1. Additionally i also installed chromedriver (but since i did it before testing, i do not know of this is needed) in order to install chromedriver, follow the steps on previous step :v

    2. Enjoy and thank me!

    Sample selenium code

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    driver = webdriver.Opera()
    driver.get("http://www.python.org")
    assert "Python" in driver.title
    elem = driver.find_element_by_name("q")
    elem.clear()
    elem.send_keys("pycon")
    elem.send_keys(Keys.RETURN)
    assert "No results found." not in driver.page_source
    driver.quit()
    
    0 讨论(0)
  • 2020-11-21 07:39

    Had the same issue. I am running the selenium script on Google cloud VM.

    options.addArguments("--headless");
    

    The above line resolved my issue. I removed the other optional arguments. I think the rest lines of code mentioned in other answers did not have any effect on resolving the issue on the cloud VM.

    0 讨论(0)
提交回复
热议问题