Skip to content

[py]: return message as part of exception in execute method #15751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions py/selenium/webdriver/remote/websocket_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

from websocket import WebSocketApp # type: ignore

from selenium.common import WebDriverException

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -65,7 +67,12 @@ def execute(self, command):
response = self._messages.pop(current_id)

if "error" in response:
raise Exception(response["error"])
error = response["error"]
if "message" in response:
error_msg = f"{error}: {response['message']}"
raise WebDriverException(error_msg)
else:
raise WebDriverException(error)
else:
result = response["result"]
return self._deserialize_result(result, command)
Expand Down Expand Up @@ -97,7 +104,7 @@ def _serialize_command(self, command):
def _deserialize_result(self, result, command):
try:
_ = command.send(result)
raise Exception("The command's generator function did not exit when expected!")
raise WebDriverException("The command's generator function did not exit when expected!")
except StopIteration as exit:
return exit.value

Expand Down
Loading