Skip to content

Commit 4bb5353

Browse files
authored
[py] add execute_cdp_cmd to Remote (#14809)
* [py] add execute_cdp_cmd to Remote * use inherited method
1 parent cc58a4e commit 4bb5353

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

py/selenium/webdriver/chromium/webdriver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def execute_cdp_cmd(self, cmd: str, cmd_args: dict):
138138
For example to getResponseBody:
139139
{'base64Encoded': False, 'body': 'response body string'}
140140
"""
141-
return self.execute("executeCdpCommand", {"cmd": cmd, "params": cmd_args})["value"]
141+
return super().execute_cdp_cmd(cmd, cmd_args)
142142

143143
def get_sinks(self) -> list:
144144
""":Returns: A list of sinks available for Cast."""

py/selenium/webdriver/remote/webdriver.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,26 @@ def _unwrap_value(self, value):
361361
return list(self._unwrap_value(item) for item in value)
362362
return value
363363

364+
def execute_cdp_cmd(self, cmd: str, cmd_args: dict):
365+
"""Execute Chrome Devtools Protocol command and get returned result The
366+
command and command args should follow chrome devtools protocol
367+
domains/commands, refer to link
368+
https://chromedevtools.github.io/devtools-protocol/
369+
370+
:Args:
371+
- cmd: A str, command name
372+
- cmd_args: A dict, command args. empty dict {} if there is no command args
373+
:Usage:
374+
::
375+
376+
driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': requestId})
377+
:Returns:
378+
A dict, empty dict {} if there is no result to return.
379+
For example to getResponseBody:
380+
{'base64Encoded': False, 'body': 'response body string'}
381+
"""
382+
return self.execute("executeCdpCommand", {"cmd": cmd, "params": cmd_args})["value"]
383+
364384
def execute(self, driver_command: str, params: dict = None) -> dict:
365385
"""Sends a command to be executed by a command.CommandExecutor.
366386

0 commit comments

Comments
 (0)