Testing with Chromium using Selenium and Python


Question

I have the following code

import time

from selenium import webdriver
import selenium.webdriver.chrome.service as service

chromedriver_path = "/Users/stephen/Downloads/chromedriver2_mac32_0.8/chromedriver"

chromium_path = "/Users/stephen/Downloads/chrome-mac/Chromium.app/Contents/MacOs/Chromium"

service = service.Service(chromedriver_path)
service.start()
capabilities = {'chrome.binary': chromium_path}
driver = webdriver.Remote(
    service.service_url,
    desired_capabilities=capabilities)
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
driver.quit()

Unfortunately, when I run the above Python script, Selenium very politely completely ignores the fact that I wanted to use Chromium and instead uses my default Google Chrome. To be clear, it does exactly what the script specifies, it is just that it is using Chrome and not Chromium.

Obviously, I am doing something wrong. I am basing my attempts off of the following pages.

https://code.google.com/p/chromedriver/wiki/GettingStarted

http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.webdriver.html?highlight=capabilities

What do I need to do to use the Chromium web browser with Selenium (in Python)?

1
4
5/29/2013 4:23:47 PM

The desired_capabilities option is for options passed on to the general selenium driver code. Options used by the chrome driver, including the chrom(e|ium) binary location, are passed in using chrome_options as follows:

from selenium.webdriver.chrome.options import Options
opts = Options()
opts.binary_location = chromium_path
driver = webdriver.Chrome(chrome_options=opts)
10
8/23/2013 12:52:24 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon