Skip to content

Commit

Permalink
Clean up Firefox WebDriver constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
davehunt authored and AutomatedTester committed May 18, 2016
1 parent 5e520b8 commit 62763bc
Showing 1 changed file with 10 additions and 32 deletions.
42 changes: 10 additions & 32 deletions py/selenium/webdriver/firefox/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,22 @@ class WebDriver(RemoteWebDriver):

def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
capabilities=None, proxy=None, executable_path="wires", firefox_options=None):
self.profile = firefox_profile
self.binary = firefox_binary
if firefox_options is None:
capabilities = capabilities or DesiredCapabilities.FIREFOX.copy()

if self.profile is None:
self.profile = FirefoxProfile()
self.profile = firefox_profile or FirefoxProfile()
self.profile.native_events_enabled = (
self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled)

self.profile.native_events_enabled = (
self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled)
self.binary = firefox_binary or capabilities.get("binary", FirefoxBinary())

if capabilities is None:
capabilities = DesiredCapabilities.FIREFOX

if self.binary is None:
self.binary = capabilities.get("binary") or FirefoxBinary()

firefox_options = Options()
firefox_options.binary_location = self.binary if isinstance(self.binary, basestring) else self.binary._get_firefox_start_cmd()
firefox_options.profile = self.profile

if capabilities is None:
capabilities = firefox_options.to_capabilities()
else:
capabilities.update(firefox_options.to_capabilities())
self.options = firefox_options or Options()
self.options.binary_location = self.binary if isinstance(self.binary, basestring) else self.binary._get_firefox_start_cmd()
self.options.profile = self.profile
capabilities.update(self.options.to_capabilities())

# marionette
if capabilities.get("marionette"):
self.binary = firefox_options.binary_location
if isinstance(firefox_options.binary_location, FirefoxBinary):
self.binary = firefox_options.binary_location._get_firefox_start_cmd()

self.service = Service(executable_path, firefox_binary=self.binary)
self.service = Service(executable_path, firefox_binary=self.options.binary_location)
self.service.start()

executor = FirefoxRemoteConnection(
Expand All @@ -93,12 +77,6 @@ def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
if proxy is not None:
proxy.add_to_capabilities(capabilities)

if self.binary is None:
self.binary = firefox_options.binary_location or FirefoxBinary()

if self.profile is None:
self.profile = firefox_options.profile or FirefoxProfile()

executor = ExtensionConnection("127.0.0.1", self.profile,
self.binary, timeout)
RemoteWebDriver.__init__(self,
Expand Down

0 comments on commit 62763bc

Please sign in to comment.