Skip to content
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

[py] Upgraded WebElement Docstrings #15056

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

shbenzer
Copy link
Contributor

@shbenzer shbenzer commented Jan 9, 2025

User description

Description

Upgraded docstrings in webelement.py to be informative and pep compliant

Motivation and Context

Documentation, PEP compliance, etc.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Documentation


Description

  • Enhanced docstrings for all methods in webelement.py.

  • Added detailed parameter, return, and example sections.

  • Improved PEP compliance and readability of docstrings.

  • Provided usage examples for better developer guidance.


Changes walkthrough 📝

Relevant files
Documentation
webelement.py
Enhanced docstrings with detailed examples and PEP compliance

py/selenium/webdriver/remote/webelement.py

  • Updated docstrings for all methods and properties.
  • Added detailed sections for parameters, returns, and examples.
  • Improved clarity and PEP compliance of documentation.
  • Provided usage examples for better understanding.
  • +245/-71

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    qodo-merge-pro bot commented Jan 9, 2025

    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

    Incomplete Example

    Several docstring examples are incomplete and don't show the full usage/result, like tag_name() and text() properties. This could make it harder for developers to understand the expected behavior.

    @property
    def tag_name(self) -> str:
        """This element's ``tagName`` property.
    
        Returns:
        --------
        str : The tag name of the element.
    
        Example:
        --------
        >>> element = driver.find_element(By.ID, 'foo')
        """
        return self._execute(Command.GET_ELEMENT_TAG_NAME)["value"]

    Copy link
    Contributor

    qodo-merge-pro bot commented Jan 9, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Fix incorrect docstring description that misrepresents the property's functionality

    The example in the docstring for accessible_name property incorrectly states it
    returns "ARIA Level" when it actually returns the accessible name. Update the
    docstring to accurately reflect the property's purpose.

    py/selenium/webdriver/remote/webelement.py [443-454]

     @property
     def accessible_name(self) -> str:
    -    """Returns the ARIA Level of the current webelement.
    +    """Returns the computed accessible name of the current webelement.
     
         Returns:
         --------
    -    str : The ARIA Level of the element.
    +    str : The accessible name of the element.
         
         Example:
         --------
         >>> name = element.accessible_name
         """
         return self._execute(Command.GET_ELEMENT_ARIA_LABEL)["value"]
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The docstring incorrectly states the property returns "ARIA Level" when it actually returns the accessible name. This is a significant documentation error that could mislead developers about the property's functionality.

    8
    General
    Complete the example in the docstring to demonstrate actual property usage

    The example in the docstring for tag_name property is incomplete and doesn't show
    how to use the property. Add a complete example showing property usage.

    py/selenium/webdriver/remote/webelement.py [83-94]

     @property
     def tag_name(self) -> str:
         """This element's ``tagName`` property.
         
         Returns:
         --------
         str : The tag name of the element.
         
         Example:
         --------
         >>> element = driver.find_element(By.ID, 'foo')
    +    >>> print(element.tag_name)  # Prints 'div' if element is a div
         """
         return self._execute(Command.GET_ELEMENT_TAG_NAME)["value"]
    • Apply this suggestion
    Suggestion importance[1-10]: 4

    Why: The suggestion improves documentation clarity by showing how to actually use the tag_name property, but it's a minor enhancement since the basic property usage is relatively intuitive.

    4

    @shbenzer shbenzer changed the title Upgraded WebElement Docstrings [py] Upgraded WebElement Docstrings Jan 9, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant