diff --git a/py/selenium/webdriver/remote/remote_connection.py b/py/selenium/webdriver/remote/remote_connection.py index 7511dc3bce9fb..f66d343da5932 100644 --- a/py/selenium/webdriver/remote/remote_connection.py +++ b/py/selenium/webdriver/remote/remote_connection.py @@ -476,8 +476,8 @@ def _request(self, method, url, body=None): request.add_header('Content-Type', 'application/json;charset=UTF-8') if parsed_url.username: - base64string = base64.b64encode('%s:%s' % (parsed_url.username, parsed_url.password)) - request.add_header("Authorization", "Basic %s" % base64string) + base64string = base64.b64encode('{0.username}:{0.password}'.format(parsed_url).encode()) + request.add_header('Authorization', 'Basic {}'.format(base64string).decode()) if password_manager: opener = url_request.build_opener(url_request.HTTPRedirectHandler(),