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