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 1414
1515from typing import Any , Dict , Union
1616
17- import base64
18-
19- import binascii
20-
2117from appium .protocols .webdriver .can_execute_commands import CanExecuteCommands
2218
2319from ..mobilecommand import MobileCommand as Command
@@ -151,13 +147,8 @@ def _add_commands(self) -> None:
151147
152148
153149def _adjust_image_payload (payload : Base64Payload ) -> str :
154- if isinstance (payload , str ):
155- return payload
156150 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' )
163154
You can’t perform that action at this time.
0 commit comments