Selenium使用Chromium代替Google Chrome

21

我最初安装了Chromium,并准备好让Selenium测试与其一起运行(我有chromeDriver,并创建了符号链接google-chrome,指向chromium-browser)。一切都运行得很顺利。

后来,我安装了Google Chrome浏览器以调试某些Node.js应用程序,从那时起,Selenium打开的是Google Chrome而不是Chromium。

我无法弄清如何使selenium再次打开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
1个回答

26

这些文档中得知:"对于Linux系统,ChromeDriver希望/usr/bin/google-chrome是指向实际Chrome二进制文件的符号链接。另请参见关于覆盖Chrome二进制文件位置的部分。"不幸的是,该页面上似乎不存在那个部分,但我想在其他地方找到了它:在非标准位置中执行,所以可以这样做:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接