You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduced the execute_cdp_cmd method to the Remote WebDriver class, enabling the execution of Chrome DevTools Protocol commands.
This enhancement allows users to execute specific browser commands directly through the Remote WebDriver, similar to the existing functionality in the Chrome WebDriver.
The method takes a command name and a dictionary of command arguments, returning the result of the command execution.
Changes walkthrough 📝
Relevant files
Enhancement
webdriver.py
Add `execute_cdp_cmd` method to Remote WebDriver
py/selenium/webdriver/remote/webdriver.py
Added execute_cdp_cmd method to the Remote WebDriver class.
The method allows execution of Chrome DevTools Protocol commands.
Provides a way to pass command name and arguments.
def execute_cdp_cmd(self, cmd: str, cmd_args: dict):
+ if not cmd or not isinstance(cmd, str):+ raise ValueError("Command must be a non-empty string")+ if not isinstance(cmd_args, dict):+ raise ValueError("Command arguments must be a dictionary")
return self.execute("executeCdpCommand", {"cmd": cmd, "params": cmd_args})["value"]
Apply this suggestion
Suggestion importance[1-10]: 8
Why: The suggestion adds crucial input validation to prevent potential runtime errors and provides clear error messages, which is especially important for a public API method that interfaces with Chrome DevTools Protocol.
@VietND96 Doesn't this create a duplication as we already have the same method in ChromiumDriver? I am not sure how to re-use it, but maybe we can at least remove it from ChromiumDriver.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Implements
execute_cdp_cmdfor Remote WebDriverMotivation and Context
Implements #14799 as it should be accessible via Remote driver as well since Grid provides the endpoints and the underlying command executor
Types of changes
Checklist
PR Type
Enhancement
Description
execute_cdp_cmdmethod to the Remote WebDriver class, enabling the execution of Chrome DevTools Protocol commands.Changes walkthrough 📝
webdriver.py
Add `execute_cdp_cmd` method to Remote WebDriverpy/selenium/webdriver/remote/webdriver.py
execute_cdp_cmdmethod to the Remote WebDriver class.