From ec70007b3992ba5843455b5d7be7a61a919f5d26 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Tue, 15 Oct 2024 18:54:39 +0000 Subject: [PATCH] [py] Remote connection throws resp status code when data is empty (#14601) 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..d3a45ae5e4067 100644 --- a/py/selenium/webdriver/remote/remote_connection.py +++ b/py/selenium/webdriver/remote/remote_connection.py @@ -336,7 +336,9 @@ def _request(self, method, url, body=None): if 300 <= statuscode < 304: return self._request("GET", response.headers.get("location", None)) if 399 < statuscode <= 500: - return {"status": statuscode, "value": data} + if statuscode == 401: + return {"status": statuscode, "value": "Authorization Required"} + 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(";")