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(";")