File tree Expand file tree Collapse file tree 1 file changed +3
-12
lines changed
appium/webdriver/extensions Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change 14
14
15
15
from typing import Any , Dict , Union
16
16
17
- import base64
18
-
19
- import binascii
20
-
21
17
from appium .protocols .webdriver .can_execute_commands import CanExecuteCommands
22
18
23
19
from ..mobilecommand import MobileCommand as Command
@@ -151,13 +147,8 @@ def _add_commands(self) -> None:
151
147
152
148
153
149
def _adjust_image_payload (payload : Base64Payload ) -> str :
154
- if isinstance (payload , str ):
155
- return payload
156
150
try :
157
- b64_str = payload .decode ('ascii' )
158
- base64 .b64decode (payload ,validate = True )
159
- return b64_str
160
- except (UnicodeDecodeError , binascii .Error ):
161
- return base64 .b64encode (payload ).decode ('ascii' )
162
-
151
+ return payload if isinstance (payload , str ) else payload .decode ('utf-8' )
152
+ except UnicodeDecodeError as e :
153
+ raise ValueError ('The image payload cannot be serialized to a string. Make sure to base64-encode it first' )
163
154
You can’t perform that action at this time.
0 commit comments