Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

node.js - Selenium use Chromium instead of google-chrome

I first installed Chromium and prepared my Selenium tests to run with it (I have the chromeDriver and I did create the symbolic link google-chrome pointing to chromium-browser). Everything was running smooth.

Later I did install the google-chrome browser to debug some node.js application and since then Selenium opens Google Chrome instead of Chromium.

I can not figure out how to get back selenium opening Chromium. The synmbolic link does exist and points to chromium-browser.

How to run Selenium with Chromium when google-chrome is also available on the system?

UPDATE 1: what about 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From these docs: "For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. See also the section on overriding the Chrome binary location ." Unfortunately that section does not appear to exist on that page but I think I found it elsewhere: executing in a non-standard location, so that's the way to go:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...