|
23 | 23 | from selenium.webdriver.remote.remote_connection import RemoteConnection |
24 | 24 |
|
25 | 25 | from appium.common.logger import logger |
26 | | -from appium.webdriver.command_method import CommandMethod |
27 | 26 | from appium.webdriver.common.mobileby import MobileBy |
28 | 27 |
|
29 | 28 | from .appium_connection import AppiumConnection |
|
83 | 82 | # Add appium prefix for the non-W3C capabilities |
84 | 83 |
|
85 | 84 |
|
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]]]]: |
87 | 86 | appium_prefix = 'appium:' |
88 | 87 |
|
89 | 88 | caps = copy.deepcopy(caps) |
90 | 89 | profile = caps.get('firefox_profile') |
91 | | - first_match = {} |
| 90 | + always_match = {} |
92 | 91 | if caps.get('proxy') and caps['proxy'].get('proxyType'): |
93 | 92 | caps['proxy']['proxyType'] = caps['proxy']['proxyType'].lower() |
94 | 93 | for k, v in caps.items(): |
95 | 94 | 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 |
97 | 96 | if k in _W3C_CAPABILITY_NAMES or _EXTENSION_CAPABILITY in k: |
98 | | - first_match[k] = v |
| 97 | + always_match[k] = v |
99 | 98 | else: |
100 | 99 | if not k.startswith(appium_prefix): |
101 | | - first_match[appium_prefix + k] = v |
| 100 | + always_match[appium_prefix + k] = v |
102 | 101 | if profile: |
103 | | - moz_opts = first_match.get('moz:firefoxOptions', {}) |
| 102 | + moz_opts = always_match.get('moz:firefoxOptions', {}) |
104 | 103 | # If it's already present, assume the caller did that intentionally. |
105 | 104 | if 'profile' not in moz_opts: |
106 | 105 | # Don't mutate the original capabilities. |
107 | 106 | new_opts = copy.deepcopy(moz_opts) |
108 | 107 | 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': [{}]} |
111 | 110 |
|
112 | 111 |
|
113 | 112 | T = TypeVar('T', bound='WebDriver') |
@@ -259,7 +258,7 @@ def __init__( |
259 | 258 | browser_profile: str = None, |
260 | 259 | proxy: str = None, |
261 | 260 | keep_alive: bool = True, |
262 | | - direct_connection: bool = False, |
| 261 | + direct_connection: bool = True, |
263 | 262 | extensions: List[T] = [], |
264 | 263 | strict_ssl: bool = True, |
265 | 264 | ): |
@@ -334,7 +333,7 @@ def _update_command_executor(self, keep_alive: bool) -> None: |
334 | 333 | path = self.caps[direct_path] |
335 | 334 | executor = f'{protocol}://{hostname}:{port}{path}' |
336 | 335 |
|
337 | | - logger.info('Updated request endpoint to %s', executor) |
| 336 | + logger.debug('Updated request endpoint to %s', executor) |
338 | 337 | # Override command executor |
339 | 338 | self.command_executor = RemoteConnection(executor, keep_alive=keep_alive) |
340 | 339 | self._addCommands() |
@@ -373,9 +372,6 @@ def start_session(self, capabilities: Dict, browser_profile: Optional[str] = Non |
373 | 372 | if self.caps is None: |
374 | 373 | self.caps = response.get('capabilities') |
375 | 374 |
|
376 | | - # Double check to see if we have a W3C Compliant browser |
377 | | - self.command_executor.w3c = True |
378 | | - |
379 | 375 | def _merge_capabilities(self, capabilities: Dict) -> Dict[str, Any]: |
380 | 376 | """Manage capabilities whether W3C format or MJSONWP format""" |
381 | 377 | w3c_caps = _make_w3c_caps(capabilities) |
|
0 commit comments