Skip to content

[py] Adding Note to enable_webextensions() regarding CDP (plus gen docstring updates) #15927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 23, 2025

Conversation

shbenzer
Copy link
Contributor

@shbenzer shbenzer commented Jun 20, 2025

User description

🔗 Related Issues

Adds docstring discussed in #15794

💥 What does this PR do?

Adds docstring discussed in #15794 and makes general docstring QOL upgrades

🔄 Types of changes

  • Cleanup (formatting, renaming)

PR Type

Documentation


Description

  • Standardized docstring format from :Args: to Parameters: section

  • Added important CDP limitation note to enable_webextensions() method

  • Enhanced docstring formatting and structure consistency


Changes walkthrough 📝

Relevant files
Documentation
options.py
Standardize docstrings and add CDP warning                             

py/selenium/webdriver/chromium/options.py

  • Converted all :Args: sections to standardized Parameters: format
  • Added detailed note about CDP limitations when webextensions enabled
  • Improved docstring formatting and structure consistency
  • Enhanced return value documentation format
  • +34/-19 

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @shbenzer shbenzer requested a review from navin772 June 20, 2025 22:38
    @selenium-ci selenium-ci added the C-py Python Bindings label Jun 20, 2025
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Documentation Inconsistency

    The add_experimental_option method docstring lacks the standardized Parameters: section header while other methods have been updated to use this format. This creates inconsistency in the documentation style.

    def add_experimental_option(self, name: str, value: Union[str, int, dict, list[str]]) -> None:
        """Adds an experimental option which is passed to chromium.
    
        Parameters:
        ----------
          name: The experimental option name.
          value: The option value.
        """
        self._experimental_options[name] = value
    Missing Docstring

    The getter property enable_webextensions has an incomplete docstring that only contains the return description but lacks proper formatting and structure compared to other methods in the file.

    """:Returns: Whether webextension support is enabled for Chromium-based browsers.
        True if webextension support is enabled, False otherwise.
    """
    return self._enable_webextensions

    @shbenzer shbenzer requested a review from cgoldberg June 20, 2025 22:38
    Copy link
    Contributor

    qodo-merge-pro bot commented Jun 20, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @shbenzer
    Copy link
    Contributor Author

    @cgoldberg new format script is great, nice job

    @cgoldberg
    Copy link
    Contributor

    LGTM, but we should also improve the error that is raised when this situation occurs.

    In py/selenium/webdriver/remote/webdriver.py, in the _get_cdp_details method, you can change this:

            if self.caps.get("browserName") == "chrome":
                debugger_address = self.caps.get("goog:chromeOptions").get("debuggerAddress")
            elif self.caps.get("browserName") == "MicrosoftEdge":
                debugger_address = self.caps.get("ms:edgeOptions").get("debuggerAddress")
    

    to something like this:

            try:
                if self.caps.get("browserName") == "chrome":
                    debugger_address = self.caps.get("goog:chromeOptions").get("debuggerAddress")
                elif self.caps.get("browserName") == "MicrosoftEdge":
                    debugger_address = self.caps.get("ms:edgeOptions").get("debuggerAddress")
            except AttributeError:
                raise WebDriverException("Can't get debugger address.")
    

    This will raise the exception if you try start_devtools() or bidi_connection().

    @shbenzer
    Copy link
    Contributor Author

    shbenzer commented Jun 21, 2025

    Test failure appears unrelated as changes were only made to Remote webdriver and docstrings

    Copy link
    Member

    @navin772 navin772 left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM!

    @diemol diemol merged commit c91ebdf into SeleniumHQ:trunk Jun 23, 2025
    3 checks passed
    Copy link
    Contributor

    @cgoldberg cgoldberg left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    5 participants