Skip to content

Commit 9e800a4

Browse files
committed
[py] add execute_cdp_cmd to Remote
1 parent 1210634 commit 9e800a4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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)