File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
appium/webdriver/extensions Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
-
2
+ import binascii
3
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
4
# you may not use this file except in compliance with the License.
5
5
# You may obtain a copy of the License at
14
14
15
15
from typing import Any , Dict , Union
16
16
17
+ import base64
18
+
17
19
from appium .protocols .webdriver .can_execute_commands import CanExecuteCommands
18
20
19
21
from ..mobilecommand import MobileCommand as Command
@@ -147,4 +149,13 @@ def _add_commands(self) -> None:
147
149
148
150
149
151
def _adjust_image_payload (payload : Base64Payload ) -> str :
150
- return payload if isinstance (payload , str ) else payload .decode ('utf-8' )
152
+ if isinstance (payload , str ):
153
+ return payload
154
+ try :
155
+ b64_str = payload .decode ('ascii' )
156
+ base64 .b64decode (payload ,validate = True )
157
+ return b64_str
158
+ except (UnicodeDecodeError , binascii .Error ):
159
+ return base64 .b64encode (payload ).decode ('ascii' )
160
+
161
+
You can’t perform that action at this time.
0 commit comments