Hello,
all of a sudden, I cannot use driver.page_source on some of the pages of the app I am testing. It’s been working for several years, but now I get the UnicodeDecodeError, on some pages immediately, on same pages after I make some operations on them.
I really don’t understand what has changes, because I have not made any changes in packages/library lately. Do you have any ideas?
Thank for the help!
I am using Python 3.12, Appium-Python-Client 4.1.0.
The whole error here:
.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py:448: in page_source
return self.execute(Command.GET_PAGE_SOURCE)["value"]
.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py:345: in execute
response = self.command_executor.execute(driver_command, params)
.venv\Lib\site-packages\selenium\webdriver\remote\remote_connection.py:302: in execute
return self._request(command_info[0], url, body=data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <appium.webdriver.appium_connection.AppiumConnection object at 0x00000162A435D430>
method = 'GET'
url = 'http://127.0.0.1:4723/session/ccac1b22-847f-42e6-a96c-575966088bae/source'
body = None
def _request(self, method, url, body=None):
"""Send an HTTP request to the remote server.
:Args:
- method - A string for the HTTP method to send the request with.
- url - A string for the URL to send the request to.
- body - A string for request body. Ignored unless method is POST or PUT.
:Returns:
A dictionary with the server's parsed JSON response.
"""
parsed_url = parse.urlparse(url)
headers = self.get_remote_connection_headers(parsed_url, self.keep_alive)
response = None
if body and method not in ("POST", "PUT"):
body = None
if self.keep_alive:
response = self._conn.request(method, url, body=body, headers=headers)
statuscode = response.status
else:
conn = self._get_connection_manager()
with conn as http:
response = http.request(method, url, body=body, headers=headers)
statuscode = response.status
> data = response.data.decode("UTF-8")
E UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 15896: invalid start byte
.venv\Lib\site-packages\selenium\webdriver\remote\remote_connection.py:329: UnicodeDecodeError