Appium-Python-Client 6.1.7__py3-none-any.whl → 6.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- appium/webdriver/errorhandler.py +59 -95
- {appium_python_client-6.1.7.dist-info → appium_python_client-6.1.8.dist-info}/METADATA +1 -1
- {appium_python_client-6.1.7.dist-info → appium_python_client-6.1.8.dist-info}/RECORD +5 -5
- {appium_python_client-6.1.7.dist-info → appium_python_client-6.1.8.dist-info}/WHEEL +0 -0
- {appium_python_client-6.1.7.dist-info → appium_python_client-6.1.8.dist-info}/licenses/LICENSE +0 -0
appium/webdriver/errorhandler.py
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
import json
|
|
16
|
-
from
|
|
16
|
+
from http import HTTPStatus
|
|
17
17
|
from typing import Any
|
|
18
18
|
|
|
19
19
|
import selenium.common.exceptions as sel_exceptions
|
|
@@ -21,106 +21,70 @@ from selenium.webdriver.remote import errorhandler
|
|
|
21
21
|
|
|
22
22
|
import appium.common.exceptions as appium_exceptions
|
|
23
23
|
|
|
24
|
-
ERROR_TO_EXC_MAPPING: dict[str, type[sel_exceptions.WebDriverException]] = {
|
|
25
|
-
'element click intercepted': sel_exceptions.ElementClickInterceptedException,
|
|
26
|
-
'element not interactable': sel_exceptions.ElementNotInteractableException,
|
|
27
|
-
'insecure certificate': sel_exceptions.InsecureCertificateException,
|
|
28
|
-
'invalid argument': sel_exceptions.InvalidArgumentException,
|
|
29
|
-
'invalid cookie domain': sel_exceptions.InvalidCookieDomainException,
|
|
30
|
-
'invalid element state': sel_exceptions.InvalidElementStateException,
|
|
31
|
-
'invalid selector': sel_exceptions.InvalidSelectorException,
|
|
32
|
-
'invalid session id': sel_exceptions.InvalidSessionIdException,
|
|
33
|
-
'javascript error': sel_exceptions.JavascriptException,
|
|
34
|
-
'move target out of bounds': sel_exceptions.MoveTargetOutOfBoundsException,
|
|
35
|
-
'no such alert': sel_exceptions.NoAlertPresentException,
|
|
36
|
-
'no such cookie': sel_exceptions.NoSuchCookieException,
|
|
37
|
-
'no such element': sel_exceptions.NoSuchElementException,
|
|
38
|
-
'no such frame': sel_exceptions.NoSuchFrameException,
|
|
39
|
-
'no such window': sel_exceptions.NoSuchWindowException,
|
|
40
|
-
'no such shadow root': sel_exceptions.NoSuchShadowRootException,
|
|
41
|
-
'script timeout': sel_exceptions.TimeoutException,
|
|
42
|
-
'session not created': sel_exceptions.SessionNotCreatedException,
|
|
43
|
-
'stale element reference': sel_exceptions.StaleElementReferenceException,
|
|
44
|
-
'detached shadow root': sel_exceptions.NoSuchShadowRootException,
|
|
45
|
-
'timeout': sel_exceptions.TimeoutException,
|
|
46
|
-
'unable to set cookie': sel_exceptions.UnableToSetCookieException,
|
|
47
|
-
'unable to capture screen': sel_exceptions.ScreenshotException,
|
|
48
|
-
'unexpected alert open': sel_exceptions.UnexpectedAlertPresentException,
|
|
49
|
-
'unknown command': sel_exceptions.UnknownMethodException,
|
|
50
|
-
'unknown error': sel_exceptions.WebDriverException,
|
|
51
|
-
'unknown method': sel_exceptions.UnknownMethodException,
|
|
52
|
-
'unsupported operation': sel_exceptions.UnknownMethodException,
|
|
53
|
-
'element not visible': sel_exceptions.ElementNotVisibleException,
|
|
54
|
-
'element not selectable': sel_exceptions.ElementNotSelectableException,
|
|
55
|
-
'invalid coordinates': sel_exceptions.InvalidCoordinatesException,
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def format_stacktrace(original: None | str | Sequence) -> list[str]:
|
|
60
|
-
if not original:
|
|
61
|
-
return []
|
|
62
|
-
if isinstance(original, str):
|
|
63
|
-
return original.split('\n')
|
|
64
|
-
|
|
65
|
-
result: list[str] = []
|
|
66
|
-
try:
|
|
67
|
-
for frame in original:
|
|
68
|
-
if not isinstance(frame, dict):
|
|
69
|
-
continue
|
|
70
|
-
|
|
71
|
-
line = frame.get('lineNumber', '')
|
|
72
|
-
file = frame.get('fileName', '<anonymous>')
|
|
73
|
-
if line:
|
|
74
|
-
file = f'{file}:{line}'
|
|
75
|
-
meth = frame.get('methodName', '<anonymous>')
|
|
76
|
-
if 'className' in frame:
|
|
77
|
-
meth = f'{frame["className"]}.{meth}'
|
|
78
|
-
result.append(f' at {meth} ({file})')
|
|
79
|
-
except TypeError:
|
|
80
|
-
pass
|
|
81
|
-
return result
|
|
82
|
-
|
|
83
24
|
|
|
84
25
|
class MobileErrorHandler(errorhandler.ErrorHandler):
|
|
85
26
|
def check_response(self, response: dict[str, Any]) -> None:
|
|
86
|
-
"""
|
|
87
|
-
https://www.w3.org/TR/webdriver/#errors
|
|
88
|
-
"""
|
|
27
|
+
"""Handle W3C and HTTP error responses, retaining Appium-specific exception mappings."""
|
|
89
28
|
payload = response.get('value', '')
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
payload_dict = json.loads(payload)
|
|
95
|
-
except (json.JSONDecodeError, TypeError):
|
|
96
|
-
return
|
|
97
|
-
if not isinstance(payload_dict, dict):
|
|
98
|
-
return
|
|
99
|
-
value = payload_dict.get('value')
|
|
100
|
-
if not isinstance(value, dict):
|
|
101
|
-
return
|
|
102
|
-
error = value.get('error')
|
|
103
|
-
if not error:
|
|
29
|
+
payload_dict = _parse_payload_dict(payload)
|
|
30
|
+
w3c_error = _extract_w3c_error(payload_dict)
|
|
31
|
+
if w3c_error is None:
|
|
32
|
+
_raise_if_http_error(response, payload, payload_dict)
|
|
104
33
|
return
|
|
105
34
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if
|
|
35
|
+
error, value = w3c_error
|
|
36
|
+
# Pass the W3C error string as Selenium's internal status, never a
|
|
37
|
+
# JSONWP numeric status. Selenium handles data.text and stacktrace.
|
|
38
|
+
try:
|
|
39
|
+
super().check_response({'status': error, 'value': value})
|
|
40
|
+
except sel_exceptions.WebDriverException as exc:
|
|
41
|
+
if type(exc) is not sel_exceptions.WebDriverException:
|
|
42
|
+
raise
|
|
43
|
+
exception_class: type[sel_exceptions.WebDriverException]
|
|
44
|
+
if error in ('unknown command', 'unknown method', 'unsupported operation'):
|
|
45
|
+
exception_class = sel_exceptions.UnknownMethodException
|
|
46
|
+
elif exc.msg == 'No such context found.':
|
|
116
47
|
exception_class = appium_exceptions.NoSuchContextException
|
|
117
|
-
elif
|
|
48
|
+
elif exc.msg == 'That command could not be executed in the current context.':
|
|
118
49
|
exception_class = appium_exceptions.InvalidSwitchToTargetException
|
|
50
|
+
else:
|
|
51
|
+
raise
|
|
52
|
+
raise exception_class(msg=exc.msg, screen=exc.screen, stacktrace=exc.stacktrace) from exc
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _parse_payload_dict(payload: Any) -> dict[str, Any] | None:
|
|
56
|
+
if isinstance(payload, dict):
|
|
57
|
+
return payload
|
|
58
|
+
if isinstance(payload, str):
|
|
59
|
+
try:
|
|
60
|
+
loaded = json.loads(payload)
|
|
61
|
+
except ValueError:
|
|
62
|
+
return None
|
|
63
|
+
return loaded if isinstance(loaded, dict) else None
|
|
64
|
+
return None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _extract_w3c_error(payload_dict: dict[str, Any] | None) -> tuple[str, dict[str, Any]] | None:
|
|
68
|
+
if payload_dict is None:
|
|
69
|
+
return None
|
|
70
|
+
value = payload_dict.get('value')
|
|
71
|
+
if not isinstance(value, dict):
|
|
72
|
+
return None
|
|
73
|
+
error = value.get('error')
|
|
74
|
+
if not isinstance(error, str) or not error:
|
|
75
|
+
return None
|
|
76
|
+
return error, value
|
|
77
|
+
|
|
119
78
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
raise
|
|
79
|
+
def _raise_if_http_error(response: dict[str, Any], payload: Any, payload_dict: dict[str, Any] | None) -> None:
|
|
80
|
+
status = response.get('status')
|
|
81
|
+
if not isinstance(status, int) or isinstance(status, bool) or status < HTTPStatus.BAD_REQUEST:
|
|
82
|
+
return
|
|
83
|
+
if payload_dict is None:
|
|
84
|
+
msg = payload if isinstance(payload, str) and payload else f'HTTP error status: {status}'
|
|
85
|
+
raise sel_exceptions.WebDriverException(msg=msg)
|
|
86
|
+
if 'status' in payload_dict:
|
|
87
|
+
return
|
|
88
|
+
value = payload_dict.get('value')
|
|
89
|
+
msg = value if isinstance(value, str) and value else json.dumps(payload_dict)
|
|
90
|
+
raise sel_exceptions.WebDriverException(msg=msg)
|
|
@@ -278,7 +278,7 @@ appium/webdriver/client_config.py,sha256=iuVcGsBF9eGNsF_gzs8b6vZWS0iI1u7actaBGBw
|
|
|
278
278
|
appium/webdriver/clipboard_content_type.py,sha256=Tyks8xA2dqvuQGEV4iVYr-iMvB-hsQBEcu8wWBxtJ4M,661
|
|
279
279
|
appium/webdriver/command_method.py,sha256=2IgtxQMSoUiS_3nAwM4rS0Rx0avBWlX2sq2k-K79zZs,792
|
|
280
280
|
appium/webdriver/connectiontype.py,sha256=ZDiibECp-bdFkWy2_PRrJboi0bf-QQDWNsnpraScOkE,1567
|
|
281
|
-
appium/webdriver/errorhandler.py,sha256=
|
|
281
|
+
appium/webdriver/errorhandler.py,sha256=GD84AUrnby9Hrj_70rg5X_zBC5LGkwdJcY_oSdaNs00,3727
|
|
282
282
|
appium/webdriver/locator_converter.py,sha256=uUdJsX1o0E8x-StcJvO5gFFJbcRzhOmySfgPqJ0UaU4,999
|
|
283
283
|
appium/webdriver/mobilecommand.py,sha256=B_okscraJMPrN4hSyetSNddkOZ0PyTzsQvBdYHHQqvM,3162
|
|
284
284
|
appium/webdriver/switch_to.py,sha256=px12JwzTXngGWJiOfKXKaIc_QOoB1144Dv2U19jebSo,1386
|
|
@@ -319,7 +319,7 @@ appium/webdriver/extensions/flutter_integration/__init__.py,sha256=wSUl6yC2TJNla
|
|
|
319
319
|
appium/webdriver/extensions/flutter_integration/flutter_commands.py,sha256=1bAczDwqr40Rrbln321cIVG83ghar7-27aerRAKbfMs,12306
|
|
320
320
|
appium/webdriver/extensions/flutter_integration/flutter_finder.py,sha256=fq3ORd4-PGUurJn0xLUMfqg7P9sE-Syv353brgcyGfM,2039
|
|
321
321
|
appium/webdriver/extensions/flutter_integration/scroll_directions.py,sha256=y1BCEbWHJ86ivj5quhln10uwV9fWsA6nsdQ18j1Ua3E,123
|
|
322
|
-
appium_python_client-6.1.
|
|
323
|
-
appium_python_client-6.1.
|
|
324
|
-
appium_python_client-6.1.
|
|
325
|
-
appium_python_client-6.1.
|
|
322
|
+
appium_python_client-6.1.8.dist-info/METADATA,sha256=uFI1yDf9gB1TKsd49m6IHcSYeP4ScGWhowsdaWOxM3w,22201
|
|
323
|
+
appium_python_client-6.1.8.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
324
|
+
appium_python_client-6.1.8.dist-info/licenses/LICENSE,sha256=QxeKfXNmPWCfFyrXiwdVzMFPFMK0nlBrKhYLUoIcqhk,11384
|
|
325
|
+
appium_python_client-6.1.8.dist-info/RECORD,,
|
|
File without changes
|
{appium_python_client-6.1.7.dist-info → appium_python_client-6.1.8.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|