Skip to content

Commit 658cadd

Browse files
authored
chore: cleanup no longer needed code in w3c, bump dev Pipfile (#646)
chore: cleanup no longer needed code in w3c, bump dev Pipfile
1 parent c7d4193 commit 658cadd

File tree

4 files changed

+35
-43
lines changed

4 files changed

+35
-43
lines changed

Pipfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ pytest-cov = "~=3.0"
1616

1717
tox = "~=3.24"
1818

19-
httpretty = "~=1.0"
19+
httpretty = "~=1.1"
2020
python-dateutil = "~=2.8"
2121
types-python-dateutil = "~=2.8"
2222
mock = "~=4.0"
2323

2424
pylint = "~=2.11"
25-
astroid = "~=2.7"
26-
isort = "~=5.8"
25+
astroid = "~=2.8"
26+
isort = "~=5.9"
2727

2828
mypy = "~=0.910"

appium/webdriver/webdriver.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from selenium.webdriver.remote.remote_connection import RemoteConnection
2424

2525
from appium.common.logger import logger
26-
from appium.webdriver.command_method import CommandMethod
2726
from appium.webdriver.common.mobileby import MobileBy
2827

2928
from .appium_connection import AppiumConnection
@@ -83,31 +82,31 @@
8382
# Add appium prefix for the non-W3C capabilities
8483

8584

86-
def _make_w3c_caps(caps: Dict) -> Dict[str, List[Dict[str, Any]]]:
85+
def _make_w3c_caps(caps: Dict) -> Dict[str, Union[Dict[str, Any], List[Dict[str, Any]]]]:
8786
appium_prefix = 'appium:'
8887

8988
caps = copy.deepcopy(caps)
9089
profile = caps.get('firefox_profile')
91-
first_match = {}
90+
always_match = {}
9291
if caps.get('proxy') and caps['proxy'].get('proxyType'):
9392
caps['proxy']['proxyType'] = caps['proxy']['proxyType'].lower()
9493
for k, v in caps.items():
9594
if v and k in _OSS_W3C_CONVERSION:
96-
first_match[_OSS_W3C_CONVERSION[k]] = v.lower() if k == 'platform' else v
95+
always_match[_OSS_W3C_CONVERSION[k]] = v.lower() if k == 'platform' else v
9796
if k in _W3C_CAPABILITY_NAMES or _EXTENSION_CAPABILITY in k:
98-
first_match[k] = v
97+
always_match[k] = v
9998
else:
10099
if not k.startswith(appium_prefix):
101-
first_match[appium_prefix + k] = v
100+
always_match[appium_prefix + k] = v
102101
if profile:
103-
moz_opts = first_match.get('moz:firefoxOptions', {})
102+
moz_opts = always_match.get('moz:firefoxOptions', {})
104103
# If it's already present, assume the caller did that intentionally.
105104
if 'profile' not in moz_opts:
106105
# Don't mutate the original capabilities.
107106
new_opts = copy.deepcopy(moz_opts)
108107
new_opts['profile'] = profile
109-
first_match['moz:firefoxOptions'] = new_opts
110-
return {'firstMatch': [first_match]}
108+
always_match['moz:firefoxOptions'] = new_opts
109+
return {'alwaysMatch': always_match, 'firstMatch': [{}]}
111110

112111

113112
T = TypeVar('T', bound='WebDriver')
@@ -259,7 +258,7 @@ def __init__(
259258
browser_profile: str = None,
260259
proxy: str = None,
261260
keep_alive: bool = True,
262-
direct_connection: bool = False,
261+
direct_connection: bool = True,
263262
extensions: List[T] = [],
264263
strict_ssl: bool = True,
265264
):
@@ -334,7 +333,7 @@ def _update_command_executor(self, keep_alive: bool) -> None:
334333
path = self.caps[direct_path]
335334
executor = f'{protocol}://{hostname}:{port}{path}'
336335

337-
logger.info('Updated request endpoint to %s', executor)
336+
logger.debug('Updated request endpoint to %s', executor)
338337
# Override command executor
339338
self.command_executor = RemoteConnection(executor, keep_alive=keep_alive)
340339
self._addCommands()
@@ -373,9 +372,6 @@ def start_session(self, capabilities: Dict, browser_profile: Optional[str] = Non
373372
if self.caps is None:
374373
self.caps = response.get('capabilities')
375374

376-
# Double check to see if we have a W3C Compliant browser
377-
self.command_executor.w3c = True
378-
379375
def _merge_capabilities(self, capabilities: Dict) -> Dict[str, Any]:
380376
"""Manage capabilities whether W3C format or MJSONWP format"""
381377
w3c_caps = _make_w3c_caps(capabilities)

appium/webdriver/webelement.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,17 @@ def find_element(self, by: str = By.ID, value: Union[str, Dict] = None) -> T:
9595
`appium.webdriver.webelement.WebElement`
9696
"""
9797
# TODO: If we need, we should enable below converter for Web context
98-
# if self._w3c:
99-
# if by == By.ID:
100-
# by = By.CSS_SELECTOR
101-
# value = '[id="%s"]' % value
102-
# elif by == By.TAG_NAME:
103-
# by = By.CSS_SELECTOR
104-
# elif by == By.CLASS_NAME:
105-
# by = By.CSS_SELECTOR
106-
# value = ".%s" % value
107-
# elif by == By.NAME:
108-
# by = By.CSS_SELECTOR
109-
# value = '[name="%s"]' % value
98+
# if by == By.ID:
99+
# by = By.CSS_SELECTOR
100+
# value = '[id="%s"]' % value
101+
# elif by == By.TAG_NAME:
102+
# by = By.CSS_SELECTOR
103+
# elif by == By.CLASS_NAME:
104+
# by = By.CSS_SELECTOR
105+
# value = ".%s" % value
106+
# elif by == By.NAME:
107+
# by = By.CSS_SELECTOR
108+
# value = '[name="%s"]' % value
110109

111110
return self._execute(RemoteCommand.FIND_CHILD_ELEMENT, {"using": by, "value": value})['value']
112111

@@ -128,18 +127,17 @@ def find_elements(self, by: str = By.ID, value: Union[str, Dict] = None) -> List
128127
:obj:`list` of :obj:`appium.webdriver.webelement.WebElement`
129128
"""
130129
# TODO: If we need, we should enable below converter for Web context
131-
# if self._w3c:
132-
# if by == By.ID:
133-
# by = By.CSS_SELECTOR
134-
# value = '[id="%s"]' % value
135-
# elif by == By.TAG_NAME:
136-
# by = By.CSS_SELECTOR
137-
# elif by == By.CLASS_NAME:
138-
# by = By.CSS_SELECTOR
139-
# value = ".%s" % value
140-
# elif by == By.NAME:
141-
# by = By.CSS_SELECTOR
142-
# value = '[name="%s"]' % value
130+
# if by == By.ID:
131+
# by = By.CSS_SELECTOR
132+
# value = '[id="%s"]' % value
133+
# elif by == By.TAG_NAME:
134+
# by = By.CSS_SELECTOR
135+
# elif by == By.CLASS_NAME:
136+
# by = By.CSS_SELECTOR
137+
# value = ".%s" % value
138+
# elif by == By.NAME:
139+
# by = By.CSS_SELECTOR
140+
# value = '[name="%s"]' % value
143141

144142
return self._execute(RemoteCommand.FIND_CHILD_ELEMENTS, {"using": by, "value": value})['value']
145143

test/unit/webdriver/webdriver_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
from appium import version as appium_version
2222
from appium import webdriver
23-
from appium.webdriver.command_method import CommandMethod
2423
from appium.webdriver.webdriver import ExtensionBase, WebDriver
2524
from test.unit.helper.test_helper import (
2625
android_w3c_driver,
@@ -61,7 +60,6 @@ def test_create_session(self):
6160
assert request_json.get('desiredCapabilities') is not None
6261

6362
assert driver.session_id == 'session-id'
64-
assert driver.command_executor.w3c
6563

6664
@httpretty.activate
6765
def test_create_session_change_session_id(self):

0 commit comments

Comments
 (0)