我试图用一个URL启动chrome浏览器,浏览器启动后,它什么也不做。

1分钟后我看到如下错误:

Unable to open browser with url: 'https://www.google.com' (Root cause: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
  (Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)

我的配置:

Chrome浏览器:66 ChromeBrowser: 2.39.56

又及,在Firefox中一切都很好


当前回答

TL;DR:如果你使用VirtualBox共享文件夹,不要在那里创建Chrome配置文件!


我在Debian 10下遇到了这个错误,但在Ubuntu 18.04下没有发生。

在我的Selenium测试中,我想安装一个扩展,并使用以下Chrome选项:

chromeOptions.addArguments(
  `load-extension=${this.extensionDir}`,
  `user-data-dir=${this.profileDir}`,
  `disable-gpu`,
  `no-sandbox`,
  `disable-setuid-sandbox`,
  `disable-dev-shm-usage`,
);

问题是,我试图在一个非标准目录下创建一个Chrome配置文件,这是VirtualBox共享文件夹的一部分。尽管使用的是完全相同版本的Chrome和Chromedriver,但在Debian下却无法运行。

解决方案是在其他地方选择一个概要目录(例如~/chrome-profile)。

其他回答

TL;DR:如果你使用VirtualBox共享文件夹,不要在那里创建Chrome配置文件!


我在Debian 10下遇到了这个错误,但在Ubuntu 18.04下没有发生。

在我的Selenium测试中,我想安装一个扩展,并使用以下Chrome选项:

chromeOptions.addArguments(
  `load-extension=${this.extensionDir}`,
  `user-data-dir=${this.profileDir}`,
  `disable-gpu`,
  `no-sandbox`,
  `disable-setuid-sandbox`,
  `disable-dev-shm-usage`,
);

问题是,我试图在一个非标准目录下创建一个Chrome配置文件,这是VirtualBox共享文件夹的一部分。尽管使用的是完全相同版本的Chrome和Chromedriver,但在Debian下却无法运行。

解决方案是在其他地方选择一个概要目录(例如~/chrome-profile)。

我通过安装yum -y install gtk3-devel gtk3-dev -docs”来解决这个问题,它可以正常工作

我的工作环境是:

Selenium Version 3.12.0
ChromeDriver Version v2.40
Chrome 68 level

之前:

后:

没有解决方法对我有效。但这里有一个变通办法:

maxcounter=5
for counter in range(maxcounter):
    try:           
        driver = webdriver.Chrome(chrome_options=options,
                          service_log_path=logfile,
                          service_args=["--verbose", "--log-path=%s" % logfile])
        break
    except WebDriverException as e:
        print("RETRYING INITIALIZATION OF WEBDRIVER! Error: %s" % str(e))
        time.sleep(10)
        if counter==maxcounter-1:
            raise WebDriverException("Maximum number of selenium-firefox-webdriver-retries exceeded.")

我有同样的问题,但在我的情况下,chrome之前安装在用户临时文件夹,之后被重新安装到程序文件。所以这里提供的任何解决方案都帮不了我。但是如果提供了chrome.exe的路径就可以了:

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

我希望这能帮助到一些人=)

我在Ubuntu 20和Python Selenium上遇到了这个问题,我首先单独下载了chromedriver,然后使用sudo apt install chromium-browser,尽管它们是同一个版本,但这种情况一直发生。

我的修复是使用提供的chrome驱动程序,附带的回购包位于

/snap/bin/chromium.chromedriver

driver = webdriver.Chrome(chrome_options=options, executable_path='/snap/bin/chromium.chromedriver')