Skip to content

Commit dcff127

Browse files
author
AutomatedTester
committed
Add the ability to start FirefoxDriver backed with Marionette via a capability
When starting FirefoxDriver change the capability `marionette` to True and supply any marionette related capabilities to the object before starting the session.
1 parent 90a1382 commit dcff127

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

Diff for: py/selenium/webdriver/common/desired_capabilities.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DesiredCapabilities(object):
2323
"""
2424
Set of default supported desired capabilities.
2525
26-
Use this as a starting point for creating a desired capabilities object for
26+
Use this as a starting point for creating a desired capabilities object for
2727
requesting remote webdrivers for connecting to selenium server or selenium grid.
2828
2929
@@ -39,7 +39,7 @@ class DesiredCapabilities(object):
3939
capabilities['version'] = "10"
4040
4141
# Instantiate an instance of Remote WebDriver with the desired capabilities.
42-
driver = webdriver.Remote(desired_capabilities=capabilities,
42+
driver = webdriver.Remote(desired_capabilities=capabilities,
4343
command_executor=selenium_grid_url)
4444
4545
Note: Always use '.copy()' on the DesiredCapabilities object to avoid the side
@@ -52,6 +52,7 @@ class DesiredCapabilities(object):
5252
"version": "",
5353
"platform": "ANY",
5454
"javascriptEnabled": True,
55+
"marionette": False,
5556
}
5657

5758
INTERNETEXPLORER = {
@@ -122,4 +123,3 @@ class DesiredCapabilities(object):
122123
"platform": "ANY",
123124
"javascriptEnabled": True,
124125
}
125-

Diff for: py/selenium/webdriver/firefox/webdriver.py

+26-12
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class WebDriver(RemoteWebDriver):
3737
# There is no native event support on Mac
3838
NATIVE_EVENTS_ALLOWED = sys.platform != "darwin"
3939

40-
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,
40+
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
4141
capabilities=None, proxy=None, executable_path='wires'):
4242

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

52-
if self.binary is None:
53-
self.binary = FirefoxBinary()
54-
5552
if capabilities is None:
5653
capabilities = DesiredCapabilities.FIREFOX
5754

58-
if proxy is not None:
59-
proxy.add_to_capabilities(capabilities)
60-
61-
self.service = Service(executable_path, firefox_binary=self.binary)
62-
self.service.start()
63-
64-
RemoteWebDriver.__init__(self,
65-
command_executor=self.service.service_url,
55+
if "marionette" in capabilities and capabilities['marionette'] is True:
56+
# Let's use Marionette! WOOOOHOOOOO!
57+
if "binary" in capabilities:
58+
self.binary = capabilities["binary"]
59+
self.service = Service(executable_path, firefox_binary=self.binary)
60+
self.service.start()
61+
62+
RemoteWebDriver.__init__(self,
63+
command_executor=self.service.service_url,
64+
desired_capabilities=capabilities,
65+
keep_alive=True)
66+
67+
else:
68+
# Oh well... sometimes the old way is the best way.
69+
if self.binary is None:
70+
self.binary = FirefoxBinary()
71+
72+
if proxy is not None:
73+
proxy.add_to_capabilities(capabilities)
74+
75+
RemoteWebDriver.__init__(self,
76+
command_executor=ExtensionConnection("127.0.0.1", self.profile,
77+
self.binary, timeout),
6678
desired_capabilities=capabilities,
6779
keep_alive=True)
80+
81+
6882
self._is_remote = False
6983

7084
def quit(self):

0 commit comments

Comments
 (0)