Skip to content

Commit

Permalink
[py] Added more internal logging for CDP (#14668)
Browse files Browse the repository at this point in the history
Co-authored-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
shbenzer and VietND96 authored Oct 29, 2024
1 parent 9b8cfb1 commit f391cd0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions py/selenium/webdriver/common/bidi/cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,19 @@ async def execute(self, cmd: typing.Generator[dict, T, typing.Any]) -> T:
if self.session_id:
request["sessionId"] = self.session_id
request_str = json.dumps(request)
if logger.isEnabledFor(logging.DEBUG):
logger.debug(f"Sending CDP message: {cmd_id} {cmd_event}: {request_str}")
try:
await self.ws.send_message(request_str)
except WsConnectionClosed as wcc:
raise CdpConnectionClosed(wcc.reason) from None
await cmd_event.wait()
response = self.inflight_result.pop(cmd_id)
if logger.isEnabledFor(logging.DEBUG):
logger.debug(f"Received CDP message: {response}")
if isinstance(response, Exception):
if logger.isEnabledFor(logging.DEBUG):
logger.debug(f"Exception raised by {cmd_event} message: {type(response).__name__}")
raise response
return response

Expand Down

0 comments on commit f391cd0

Please # to comment.