Skip to content

Commit

Permalink
Add desired capabilities keyword to IE and Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
isaulv authored and AutomatedTester committed Mar 12, 2018
1 parent e957482 commit 8f52ceb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 9 additions & 1 deletion py/selenium/webdriver/firefox/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
timeout=30, capabilities=None, proxy=None,
executable_path="geckodriver", options=None,
log_path="geckodriver.log", firefox_options=None,
service_args=None):
service_args=None, desired_capabilities=None):
"""Starts a new local session of Firefox.
Based on the combination and specificity of the various keyword
Expand Down Expand Up @@ -101,6 +101,9 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
defaults to picking up the binary from the system path.
:param options: Instance of ``options.Options``.
:param log_path: Where to log information from the driver.
:param desired_capabilities: alias of capabilities. In future
versions of this library, this will replace 'capabilities'.
This will make the signature consistent with RemoteWebDriver.
"""
if firefox_options:
Expand All @@ -110,6 +113,11 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
self.profile = None
self.service = None

# If desired capabilities is set, alias it to capabilities.
# If both are set ignore desired capabilities.
if capabilities is None and desired_capabilities:
capabilities = desired_capabilities

if capabilities is None:
capabilities = DesiredCapabilities.FIREFOX.copy()
if options is None:
Expand Down
11 changes: 8 additions & 3 deletions py/selenium/webdriver/ie/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WebDriver(RemoteWebDriver):
def __init__(self, executable_path='IEDriverServer.exe', capabilities=None,
port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST,
log_level=DEFAULT_LOG_LEVEL, log_file=DEFAULT_LOG_FILE, options=None,
ie_options=None):
ie_options=None, desired_capabilities=None):
"""
Creates a new instance of the chrome driver.
Expand All @@ -48,6 +48,7 @@ def __init__(self, executable_path='IEDriverServer.exe', capabilities=None,
- log_level - log level you would like the service to run.
- log_file - log file you would like the service to log to.
- options: IE Options instance, providing additional IE options
- desired_capabilities: alias of capabilities; this will make the signature consistent with RemoteWebDriver.
"""
if ie_options:
warnings.warn('use options instead of ie_options', DeprecationWarning)
Expand All @@ -59,14 +60,18 @@ def __init__(self, executable_path='IEDriverServer.exe', capabilities=None,
self.log_level = log_level
self.log_file = log_file

# If both capabilities and desired capabilities are set, ignore desired capabilities.
if capabilities is None and desired_capabilities:
capabilities = desired_capabilities

if options is None:
# desired_capabilities stays as passed in
if capabilities is None:
capabilities = self.create_options().to_capabilities()
else:
if capabilities is None:
capabilities = options.to_capabilities()
else:
# desired_capabilities stays as passed in
capabilities.update(options.to_capabilities())

self.iedriver = Service(
Expand All @@ -79,7 +84,7 @@ def __init__(self, executable_path='IEDriverServer.exe', capabilities=None,
self.iedriver.start()

if capabilities is None:
capabilities = DesiredCapabilities.INTERNETEXPLORER
capabilities = DesiredCapabilities.INTERNETEXPLORER.copy()

RemoteWebDriver.__init__(
self,
Expand Down

0 comments on commit 8f52ceb

Please sign in to comment.