Skip to content

Commit

Permalink
Add the ability to start FirefoxDriver backed with Marionette via a c…
Browse files Browse the repository at this point in the history
…apability

When starting FirefoxDriver change the capability `marionette` to True
and supply any marionette related capabilities to the object before starting
the session.
  • Loading branch information
AutomatedTester committed Jul 2, 2015
1 parent 90a1382 commit dcff127
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
6 changes: 3 additions & 3 deletions py/selenium/webdriver/common/desired_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DesiredCapabilities(object):
"""
Set of default supported desired capabilities.
Use this as a starting point for creating a desired capabilities object for
Use this as a starting point for creating a desired capabilities object for
requesting remote webdrivers for connecting to selenium server or selenium grid.
Expand All @@ -39,7 +39,7 @@ class DesiredCapabilities(object):
capabilities['version'] = "10"
# Instantiate an instance of Remote WebDriver with the desired capabilities.
driver = webdriver.Remote(desired_capabilities=capabilities,
driver = webdriver.Remote(desired_capabilities=capabilities,
command_executor=selenium_grid_url)
Note: Always use '.copy()' on the DesiredCapabilities object to avoid the side
Expand All @@ -52,6 +52,7 @@ class DesiredCapabilities(object):
"version": "",
"platform": "ANY",
"javascriptEnabled": True,
"marionette": False,
}

INTERNETEXPLORER = {
Expand Down Expand Up @@ -122,4 +123,3 @@ class DesiredCapabilities(object):
"platform": "ANY",
"javascriptEnabled": True,
}

38 changes: 26 additions & 12 deletions py/selenium/webdriver/firefox/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class WebDriver(RemoteWebDriver):
# There is no native event support on Mac
NATIVE_EVENTS_ALLOWED = sys.platform != "darwin"

def __init__(self, firefox_profile=None, firefox_binary='/Users/dburns/development/mozilla/mozilla-inbound/obj-ff-dbg/dist/Nightly.app/Contents/MacOS/firefox', timeout=30,
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
capabilities=None, proxy=None, executable_path='wires'):

self.binary = firefox_binary
Expand All @@ -49,22 +49,36 @@ def __init__(self, firefox_profile=None, firefox_binary='/Users/dburns/developme
self.profile.native_events_enabled = (
self.NATIVE_EVENTS_ALLOWED and self.profile.native_events_enabled)

if self.binary is None:
self.binary = FirefoxBinary()

if capabilities is None:
capabilities = DesiredCapabilities.FIREFOX

if proxy is not None:
proxy.add_to_capabilities(capabilities)

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

RemoteWebDriver.__init__(self,
command_executor=self.service.service_url,
if "marionette" in capabilities and capabilities['marionette'] is True:
# Let's use Marionette! WOOOOHOOOOO!
if "binary" in capabilities:
self.binary = capabilities["binary"]
self.service = Service(executable_path, firefox_binary=self.binary)
self.service.start()

RemoteWebDriver.__init__(self,
command_executor=self.service.service_url,
desired_capabilities=capabilities,
keep_alive=True)

else:
# Oh well... sometimes the old way is the best way.
if self.binary is None:
self.binary = FirefoxBinary()

if proxy is not None:
proxy.add_to_capabilities(capabilities)

RemoteWebDriver.__init__(self,
command_executor=ExtensionConnection("127.0.0.1", self.profile,
self.binary, timeout),
desired_capabilities=capabilities,
keep_alive=True)


self._is_remote = False

def quit(self):
Expand Down

0 comments on commit dcff127

Please sign in to comment.