我试图用一个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中一切都很好


当前回答

我被这个问题困扰了很长一段时间,最后通过添加一个额外的选项来解决它:

options.addArguments(”——crash-dumps-dir = / tmp”)

其他回答

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)。

更新:

我能够通过这个问题,现在我能够访问chrome所需的url。

对所提供解决方案的尝试结果:

我尝试了上面提供的所有设置,但我无法解决这个问题

关于问题的解释:

根据我的观察,DevToolsActivePort文件不存在的原因是chrome无法在scoped_dirXXXXX文件夹中找到它的引用。

为解决该问题所采取的步骤

我已经杀死了所有的chrome进程和chrome驱动程序进程。 添加下面的代码来调用chrome System.setProperty(“webdriver.chrome.driver”、“pathto \ \ chromedriver.exe”); ChromeOptions选项=新的ChromeOptions(); 选项。setExperimentalOption(“useAutomationExtension”,假); WebDriver驱动=新的ChromeDriver(选项); driver.get (url);

使用上述步骤,我能够解决这个问题。

谢谢你的回答。

我用Jenkins在Ubuntu 18 LTS linux上运行selenium测试。我有这个错误,直到我像这样添加了参数'headless'(以及其他一些参数):

ChromeOptions options = new ChromeOptions();
options.addArguments("headless"); // headless -> no browser window. needed for jenkins
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--no-sandbox"); // Bypass OS security model
ChromeDriver driver = new ChromeDriver(options);

driver.get("www.google.com");

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");

老问题,但类似的问题几乎把我逼疯了,所以分享我的解决方案。其他的建议都不能解决我的问题。

当我将Docker镜像Chrome从旧版本更新到Chrome 86时,我得到了这个错误。我的设置是不相同的,但我们实例化Chrome通过一个硒webdriver。

解决方案是将选项传递为goog:chromeOptions哈希而不是chromeOptions哈希。我真的不知道这是一个硒,Chrome, Chromedriver,或其他更新,但也许某些可怜的灵魂会在未来的这个答案中找到安慰。