Skip to content

Latest commit

 

History

History
118 lines (74 loc) · 3.16 KB

firefox.rst

File metadata and controls

118 lines (74 loc) · 3.16 KB

Firefox WebDriver

Installation

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

[sudo] pip install selenium

The following applications are also required:

Geckodriver must also be available on your operating system's PATH environment variable.

Mac OS X

The recommended way is by using Homebrew:

brew install geckodriver

Usage

To use the Firefox driver, pass the string firefox when you create the Browser instance:

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

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

Headless mode

Starting with Firefox 55, Firefox can run in a headless mode.

To use headless mode, pass the headless argument when creating a new Browser instance.

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

Incognito mode

To use Firefox's incognito mode, pass the incognito argument when creating a Browser instance.

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

Specify Profile

You can specify a Firefox profile for using on Browser function using the profile keyword (passing the name of the profile as a str instance):

from splinter import Browser
browser = Browser('firefox', profile='my_profile')

If you don't specify a profile, a new temporary profile will be created (and deleted when you close the browser).

Firefox Extensions

An extension for firefox is a .xpi archive. To use an extension in Firefox webdriver profile you need to give the path of the extension, using the extensions keyword (passing the extensions as a list instance):

from splinter import Browser
browser = Browser('firefox', extensions=['extension1.xpi', 'extension2.xpi'])

After the browser is closed, extensions will be deleted from the profile, even if the profile is not a temporary one.

Selenium Capabilities

from splinter import Browser
browser = Browser('firefox', capabilities={'acceptSslCerts': True})

You can pass any selenium read-write DesiredCapabilities parameters for Firefox.

API docs

splinter.driver.webdriver.firefox.WebDriver