Skip to content

Commit

Permalink
[py] Deprecate desired_capabilities property in favour of capabilitie…
Browse files Browse the repository at this point in the history
…s property
  • Loading branch information
AutomatedTester committed Oct 7, 2020
1 parent 9220e91 commit 12202b7
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions py/selenium/webdriver/remote/webdriver.py
Expand Up @@ -189,7 +189,7 @@ def __init__(self, command_executor='http://127.0.0.1:4444',
self.command_executor = get_remote_connection(capabilities, command_executor=command_executor, keep_alive=keep_alive)
self._is_remote = True
self.session_id = None
self.capabilities = {}
self.caps = {}
self.error_handler = ErrorHandler()
self.start_client()
self.start_session(capabilities, browser_profile)
Expand Down Expand Up @@ -249,8 +249,8 @@ def name(self):
name = driver.name
"""
if 'browserName' in self.capabilities:
return self.capabilities['browserName']
if 'browserName' in self.caps:
return self.caps['browserName']
else:
raise KeyError('browserName not specified in session capabilities')

Expand Down Expand Up @@ -293,12 +293,12 @@ def start_session(self, capabilities, browser_profile=None):
if 'sessionId' not in response:
response = response['value']
self.session_id = response['sessionId']
self.capabilities = response.get('value')
self.caps = 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')
if self.caps is None:
self.caps = response.get('capabilities')

# Double check to see if we have a W3C Compliant browser
self.w3c = response.get('status') is None
Expand Down Expand Up @@ -1149,7 +1149,16 @@ def desired_capabilities(self):
"""
returns the drivers current desired capabilities being used
"""
return self.capabilities
warnings.warn("desired_capabilities is deprecated. Please call capabilities.",
DeprecationWarning, stacklevel=2)
return self.caps

@property
def capabilities(self):
"""
returns the drivers current capabilities being used.
"""
return self.caps

def get_screenshot_as_file(self, filename):
"""
Expand Down Expand Up @@ -1504,8 +1513,8 @@ async def _get_bidi_connection(self):
global cdp
import_cdp()
ws_url = None
if self.capabilities.get("se:options"):
ws_url = self.capabilities.get("se:options").get("cdp")
if self.caps.get("se:options"):
ws_url = self.caps.get("se:options").get("cdp")
else:
version, ws_url = self._get_cdp_details()

Expand All @@ -1527,7 +1536,7 @@ def _get_cdp_details(self):
import urllib3

http = urllib3.PoolManager()
debugger_address = self.capabilities.get("{0}:chromeOptions".format(self.vendor_prefix)).get("debuggerAddress")
debugger_address = self.caps.get("{0}:chromeOptions".format(self.vendor_prefix)).get("debuggerAddress")
res = http.request('GET', "http://{0}/json/version".format(debugger_address))
data = json.loads(res.data)

Expand Down

0 comments on commit 12202b7

Please sign in to comment.