Skip to content

Commit

Permalink
Update start session to handle the W3C New Session
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Apr 3, 2017
1 parent c2ae88b commit abe1f45
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def stop_client(self):
"""
pass

def start_session(self, desired_capabilities, browser_profile=None):
def start_session(self, capabilities, browser_profile=None):
"""
Creates a new session with the desired capabilities.
Expand All @@ -169,21 +169,26 @@ def start_session(self, desired_capabilities, browser_profile=None):
- javascript_enabled - Whether the new session should support JavaScript.
- browser_profile - A selenium.webdriver.firefox.firefox_profile.FirefoxProfile object. Only used if Firefox is requested.
"""
capabilities = {'desiredCapabilities': {}, 'requiredCapabilities': {}}
for k, v in desired_capabilities.items():
if k not in ('desiredCapabilities', 'requiredCapabilities'):
capabilities['desiredCapabilities'][k] = v
else:
capabilities[k].update(v)
if not isinstance(capabilities, dict):
raise InvalidArgumentException("Capabilities must be a dictionary")
w3c_caps = {"firstMatch": [], "alwaysMatch": {}}
w3c_caps.update(capabilities)
if browser_profile:
capabilities['desiredCapabilities']['firefox_profile'] = browser_profile.encoded
response = self.execute(Command.NEW_SESSION, capabilities)
w3c_caps["firstMatch"].append({"firefox_profile": browser_profile.encoded})
parameters = {"capabilities": w3c_caps,
"desiredCapabilities": capabilities}
response = self.execute(Command.NEW_SESSION, parameters)
if 'sessionId' not in response:
response = response['value']
self.session_id = response['sessionId']
self.capabilities = response['value']
self.capabilities = response.get('value')

# if capabilities is none we are probably speaking to
# a W3C endpoint
if self.capabilities is None:
self.capabilities = response.get('capabilities')

# Quick check to see if we have a W3C Compliant browser
# Double check to see if we have a W3C Compliant browser
self.w3c = response.get('status') is None

def _wrap_value(self, value):
Expand Down

0 comments on commit abe1f45

Please sign in to comment.