From e1243bd9c01d2b6d51c2eb8274303b9bf48977d3 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Tue, 15 Oct 2024 09:34:49 +0000 Subject: [PATCH] [py] Remote connection throws resp statuscode when data is empty Signed-off-by: Viet Nguyen Duc --- py/selenium/webdriver/remote/remote_connection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py/selenium/webdriver/remote/remote_connection.py b/py/selenium/webdriver/remote/remote_connection.py index c3c28eca0cd59..b33b5c2cb6647 100644 --- a/py/selenium/webdriver/remote/remote_connection.py +++ b/py/selenium/webdriver/remote/remote_connection.py @@ -333,10 +333,12 @@ def _request(self, method, url, body=None): data = response.data.decode("UTF-8") LOGGER.debug("Remote response: status=%s | data=%s | headers=%s", response.status, data, response.headers) try: + if statuscode == 401: + return {"status": statuscode, "value": "Authorization Required"} if 300 <= statuscode < 304: return self._request("GET", response.headers.get("location", None)) if 399 < statuscode <= 500: - return {"status": statuscode, "value": data} + return {"status": statuscode, "value": str(statuscode) if not data else data.strip() } content_type = [] if response.headers.get("Content-Type", None): content_type = response.headers.get("Content-Type", None).split(";")