class selenium.webdriver.firefox.webdriver.WebDriver(firefox_profile=None, firefox_binary=None, timeout=30, capabilities=None, proxy=None, executable_path='geckodriver', firefox_options=None, log_path='geckodriver.log')[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 firefox_options.profile are mutually exclusive, precedence is given from how specific the setting is. capabilities is the least specific keyword argument, followed by firefox_options, followed by firefox_binary and firefox_profile.

In practice this means that if firefox_profile and firefox_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 firefox_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[“firefoxOptions”][“profile”] Base64 string, this would rank below firefox_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.
  • firefox_options – Instance of options.Options.
  • log_path – Where to log information from the driver.
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 ...

Quits the driver and close every associated window.


This Page