class selenium.webdriver.firefox.webdriver.WebDriver(firefox_profile=None, firefox_binary=None, timeout=30, capabilities=None, proxy=None, executable_path='geckodriver', options=None, service_log_path='geckodriver.log', firefox_options=None, service_args=None, desired_capabilities=None, log_path=None)[source]

Starts a new local session of Firefox.

Based on the combination and specificity of the various keyword arguments, a capabilities dictionary will be constructed that is passed to the remote end.

The keyword arguments given to this constructor are helpers to more easily allow Firefox WebDriver sessions to be customised with different options. They are mapped on to a capabilities dictionary that is passed on to the remote end.

As some of the options, such as firefox_profile and options.profile are mutually exclusive, precedence is given from how specific the setting is. capabilities is the least specific keyword argument, followed by options, followed by firefox_binary and firefox_profile.

In practice this means that if firefox_profile and options.profile are both set, the selected profile instance will always come from the most specific variable. In this case that would be firefox_profile. This will result in options.profile to be ignored because it is considered a less specific setting than the top-level firefox_profile keyword argument. Similarily, if you had specified a capabilities[“moz:firefoxOptions”][“profile”] Base64 string, this would rank below options.profile.

  • firefox_profile – Instance of FirefoxProfile object or a string. If undefined, a fresh profile will be created in a temporary location on the system.
  • firefox_binary – Instance of FirefoxBinary or full path to the Firefox binary. If undefined, the system default Firefox installation will be used.
  • timeout – Time to wait for Firefox to launch when using the extension connection.
  • capabilities – Dictionary of desired capabilities.
  • proxy – The proxy settings to us when communicating with Firefox via the extension connection.
  • executable_path – Full path to override which geckodriver binary to use for Firefox 47.0.1 and greater, which defaults to picking up the binary from the system path.
  • options – Instance of options.Options.
  • service_log_path – Where to log information from the driver.
  • desired_capabilities – alias of capabilities. In future versions of this library, this will replace ‘capabilities’. This will make the signature consistent with RemoteWebDriver.
context(*args, **kwds)[source]

Sets the context that Selenium commands are running in using a with statement. The state of the context on the server is saved before entering the block, and restored upon exiting it.

Parameters:context – Context, may be one of the class properties CONTEXT_CHROME or CONTEXT_CONTENT.

Usage example:

with selenium.context(selenium.CONTEXT_CHROME):
    # chrome scope
    ... do stuff ...
install_addon(path, temporary=None)[source]

Installs Firefox addon.

Returns identifier of installed addon. This identifier can later be used to uninstall addon.

Parameters:path – Absolute path to the addon that will be installed.
Usage :driver.install_addon(‘/path/to/firebug.xpi’)

Quits the driver and close every associated window.


Uninstalls Firefox addon using its identifier.

Usage :driver.uninstall_addon('‘)

This Page