Skip to content

Commit 9edf6eb

Browse files
fix: Handle the situation where payload is already a dictionary (#892)
1 parent 78bbb73 commit 9edf6eb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

appium/webdriver/errorhandler.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,15 @@ def check_response(self, response: Dict[str, Any]) -> None:
8686
https://www.w3.org/TR/webdriver/#errors
8787
"""
8888
payload = response.get('value', '')
89-
try:
90-
payload_dict = json.loads(payload)
91-
except (json.JSONDecodeError, TypeError):
92-
return
93-
if not isinstance(payload_dict, dict):
94-
return
89+
if isinstance(payload, dict):
90+
payload_dict = payload
91+
else:
92+
try:
93+
payload_dict = json.loads(payload)
94+
except (json.JSONDecodeError, TypeError):
95+
return
96+
if not isinstance(payload_dict, dict):
97+
return
9598
value = payload_dict.get('value')
9699
if not isinstance(value, dict):
97100
return

0 commit comments

Comments
 (0)