【问题标题】:Selenium use Chromium instead of google-chromeSelenium 使用 Chromium 而不是 google-chrome
【发布时间】:2014-07-28 16:03:23
【问题描述】:

我首先安装了 Chromium 并准备了我的 Selenium 测试以使用它运行(我有 chromeDriver,并且我确实创建了指向 chromium-browser 的符号链接 google-chrome)。一切都很顺利。

后来我确实安装了 google-chrome 浏览器来调试一些 node.js 应用程序,从那时起 Selenium 打开了 Google Chrome 而不是 Chromium。

我不知道如何找回硒打开 Chromium。 符号链接确实存在并指向 chromium-browser。

当系统上还有 google-chrome 可用时,如何使用 Chromium 运行 Selenium?

更新 1: update-alternatives 呢?

$ ls -lah /usr/bin/google-chrome
/usr/bin/google-chrome -> /etc/alternatives/google-chrome

$ ls -lah /etc/alternatives/google-chrome
/etc/alternatives/google-chrome -> /usr/lib/chromium-browser/chromium-browser

【问题讨论】:

  • 如果您没有更改 Selenium 测试套件中的任何内容,则问题一定出在操作系统、用户配置等方面。如果您提到 update-alternatives,那么我猜您使用的是 Linux。
  • @GrzegorzOledzki 是的,它必须与操作系统以及 selenium 如何启动浏览器有关,因为当我删除 google-chrome 时,一切都开始按预期工作。

标签: node.js google-chrome selenium chromium


【解决方案1】:

来自these docs:“对于 Linux 系统,ChromeDriver 期望 /usr/bin/google-chrome 成为实际 Chrome 二进制文件的符号链接。另请参阅覆盖 Chrome 二进制文件位置的部分。”不幸的是,该页面上似乎不存在该部分,但我想我在其他地方找到了它:executing in a non-standard location,所以这就是要走的路:

ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");

【讨论】:

  • 我的符号链接没问题,正如预期的那样,但 Selenium 在操作系统级别绕过了这个。尽管如此,我还是会测试二进制集操作,对于 node.js WebDriver,方法是setBinaryPath
  • setBinaryPath 成功了。非常感谢(PS:我的名声不允许投票给你的答案,对不起)
猜你喜欢
  • 2010-12-07
  • 2022-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-28
  • 2014-12-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多