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 11#!/usr/bin/env python
2-
2+ import binascii
33# Licensed under the Apache License, Version 2.0 (the "License");
44# you may not use this file except in compliance with the License.
55# You may obtain a copy of the License at
1414
1515from typing import Any , Dict , Union
1616
17+ import base64
18+
1719from appium .protocols .webdriver .can_execute_commands import CanExecuteCommands
1820
1921from ..mobilecommand import MobileCommand as Command
@@ -147,4 +149,13 @@ def _add_commands(self) -> None:
147149
148150
149151def _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