Skip to content

Commit

Permalink
[py] add execute_cdp_cmd to Remote (SeleniumHQ#14809)
Browse files Browse the repository at this point in the history
* [py] add execute_cdp_cmd to Remote
* use inherited method
  • Loading branch information
Delta456 authored Dec 9, 2024
1 parent cc58a4e commit 4bb5353
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion py/selenium/webdriver/chromium/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def execute_cdp_cmd(self, cmd: str, cmd_args: dict):
For example to getResponseBody:
{'base64Encoded': False, 'body': 'response body string'}
"""
return self.execute("executeCdpCommand", {"cmd": cmd, "params": cmd_args})["value"]
return super().execute_cdp_cmd(cmd, cmd_args)

def get_sinks(self) -> list:
""":Returns: A list of sinks available for Cast."""
Expand Down
20 changes: 20 additions & 0 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,26 @@ def _unwrap_value(self, value):
return list(self._unwrap_value(item) for item in value)
return value

def execute_cdp_cmd(self, cmd: str, cmd_args: dict):
"""Execute Chrome Devtools Protocol command and get returned result The
command and command args should follow chrome devtools protocol
domains/commands, refer to link
https://chromedevtools.github.io/devtools-protocol/
:Args:
- cmd: A str, command name
- cmd_args: A dict, command args. empty dict {} if there is no command args
:Usage:
::
driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': requestId})
:Returns:
A dict, empty dict {} if there is no result to return.
For example to getResponseBody:
{'base64Encoded': False, 'body': 'response body string'}
"""
return self.execute("executeCdpCommand", {"cmd": cmd, "params": cmd_args})["value"]

def execute(self, driver_command: str, params: dict = None) -> dict:
"""Sends a command to be executed by a command.CommandExecutor.
Expand Down

0 comments on commit 4bb5353

Please sign in to comment.