Fetching contributors…
Cannot retrieve contributors at this time
164 lines (100 sloc) 4.57 KB

Chrome WebDriver

Chrome WebDriver is provided by Selenium2. To use it, you need to install Selenium2 via pip:

$ [sudo] pip install selenium

It's important to note that you also need to have Google Chrome installed in your machine.

Chrome can also be used from a custom path. To do this pass the executable path as a dictionary to the **kwargs argument. The dictionary should be set up with executable_path as the key and the value set to the path to the executable file.

from splinter import Browser
executable_path = {'executable_path':'</path/to/chrome>'}

browser = Browser('chrome', **executable_path)

Setting up Chrome WebDriver

In order to use Google Chrome with Splinter, since we're using Selenium 2.3.x, you need to setup Chrome webdriver properly.

Mac OS X

The recommended way is by using Homebrew:

$ brew cask install chromedriver


Go to the download page on the Chromium project and choose the correct version for your Linux installation. Then extract the downloaded file in a directory in the PATH (e.g. /usr/bin). You can also extract it to any directory and add that directory to the PATH:

Linux 64bits

$ cd $HOME/Downloads
$ wget
$ unzip

$ mkdir -p $HOME/bin
$ mv chromedriver $HOME/bin
$ echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile


Note: We don't provide official support for Windows, but you can try it by yourself.

All you need to do is go to download page on Selenium project and choose "ChromeDriver server for win". Your browser will download a zip file, extract it and add the .exe file to your PATH.

If you don't know how to add an executable to the PATH on Windows, check these link out:

Using Chrome WebDriver

To use the Chrome driver, all you need to do is pass the string chrome when you create the Browser instance:

from splinter import Browser
browser = Browser('chrome')

Note: if you don't provide any driver to the Browser function, firefox will be used.

Note: if you have trouble with $HOME/.bash_profile, you can try $HOME/.bashrc.

Using headless option for Chrome

Starting with Chrome 59, we can run Chrome as a headless browser. Make sure you read google developers updates

from splinter import Browser
browser = Browser('chrome', headless=True)

Using incognito option for Chrome

We can run Chrome as a incognito browser.

from splinter import Browser
browser = Browser('chrome', incognito=True)

Using emulation mode in Chrome

Chrome options can be passed to customize Chrome's behaviour; it is then possible to leverage the experimental emulation mode.

from selenium import webdriver
from splinter import Browser

mobile_emulation = {"deviceName": "Google Nexus 5"}
chrome_options = webdriver.ChromeOptions()
browser = Browser('chrome', options=chrome_options)

refer to chrome driver documentation

API docs

.. autoclass::