22

In the Selenium options (on Firefox) I can find Custom browser.

Is it possible to use this option to run a Selenium test in Chromium Browser (not Chrome)?

Robert Siemer
  • 26,279
  • 9
  • 72
  • 84
RusAlex
  • 7,639
  • 5
  • 32
  • 43

6 Answers6

28

Uh, the accepted answer doesn't answer the question. Google Chrome is based on Chromium, but they're not the same browser.

This is what you want: (since Chromium isn't officially supported)

DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*custom C:/path/to/chromium.exe" , "www.google.com");
selenium.start();

Edit 2018-08: Looks like the accepted answer changed to a copy of this one several years later, so my original comment is no longer correct. I'm leaving it there, but struck out, because the votes are misleading if I straight remove it.

Izkata
  • 8,242
  • 2
  • 38
  • 48
  • @SAndrew Already there. Looks like the other answer changed it a few years ago to a copy of mine, instead of what I was referring to. – Izkata Aug 27 '18 at 14:53
  • Can you now pls add some demo code on how to use it. – S Andrew Aug 27 '18 at 15:02
  • @SAndrew This is a configuration line in the documentation. If you're having trouble with it, you should ask a new question. – Izkata Aug 27 '18 at 15:55
9

On unix systems, you can do something like

sudo ln -s /usr/lib/chromium-browser/chromium-browser /usr/bin/google-chrome

and then you can use "*googlechrome" as the lauch parm when creating your DefaultSelenium instance.

mryan
  • 308
  • 2
  • 5
4

Yes. For Chromium use:

DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*custom path/to/chromium" , "www.google.com");
selenium.start();

The other options that you can use are *custom, *chrome(note: this is not Google chrome, its a firefox mode only), *googlechrome, *iexplore. Please check selenium documentation for complete list of the modes.

EDIT: Changed googlechrome to chromium

Pablo Guerrero
  • 596
  • 1
  • 6
  • 18
9ikhan
  • 1,157
  • 3
  • 11
  • 22
2

It's probably too easy, and I'm going to figure out what I did that is horribly wrong, but...

    ChromeOptions options = new ChromeOptions();

    options.BinaryLocation = "C:\Program Files (x86)\Chromium\Application\chrome.exe");

    using (var chrome = new ChromeDriver(options))

appears to work...

Steve
  • 888
  • 9
  • 12
2

(Python)

You can use chromium-chromedriver instead of the vanilla chromedriver. It can be installed via apt-get like "sudo apt-get install chromium-chromedriver"

In my scripts I then configure the chromebrowser and driver to use the chromium exe and chromedriver exe like:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.BinaryLocation = "/usr/bin/chromium-browser"

driver = webdriver.Chrome(executable_path="/usr/bin/chromedriver",options=options)
driver.get("https://www.google.com")
Dylan
  • 19
  • 2
0

Yes, it is...

In a Linux you can install, to use without a xwindow (ex.: in a webserver) too... Its nice to some tests.

apt install chromium-shell 

In a code, you'll need a chromedriver, look this:

chromedriver

In this case i'll use a python code, to open a chromium in a headless mode:

def startBot():
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')
    driver = webdriver.Chrome('/opt/chromedriver85', options=chrome_options)
    #driver.set_window_size(1366, 728)
    #aguardar carregamento em segundos
    driver.implicitly_wait(5)

    print("get url...")
    driver.get("https://www.google.com")

Obs.:

A headless browser is a great tool for automated testing and server environments where you don't need a visible UI shell. (source)

That's it!

Deividson Calixto
  • 159
  • 1
  • 1
  • 7