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] Added Deprecation of WebElement.get_attribute() per #13334 #14675

Merged

Conversation

shbenzer
Copy link
Contributor

@shbenzer shbenzer commented Oct 29, 2024

User description

Description

added deprecation warning to WebElement.get_attribute()

Motivation and Context

#13334

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

enhancement, documentation


Description

  • Added a deprecation warning to the WebElement.get_attribute() method in the Selenium WebDriver Python library.
  • Users are advised to use the get_dom_attribute() method instead.
  • This change addresses issue [🚀 Feature]: deprecate WebElement.getAttribute #13334 and aims to guide users towards more modern practices.

PRDescriptionHeader.CHANGES_WALKTHROUGH

Relevant files
Enhancement
webelement.py
Deprecate `WebElement.get_attribute()` method with warning

py/selenium/webdriver/remote/webelement.py

  • Added a deprecation warning for WebElement.get_attribute().
  • Suggested using get_dom_attribute() instead.
  • +7/-0     

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

    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

    Deprecation Warning
    The deprecation warning message is missing a comma after the warning text, which may cause a syntax error.

    Copy link
    Contributor

    qodo-merge-pro bot commented Oct 29, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    ✅ Fix syntax error in warning message by adding a missing comma
    Suggestion Impact:The suggestion was implemented by adding the missing comma after the warning message string in the warnings.warn() call.

    code diff:

    -            "using WebElement.get_attribute() has been deprecated. Please use get_dom_attribute() instead."
    +            "using WebElement.get_attribute() has been deprecated. Please use get_dom_attribute() instead.",

    Add the missing comma after the warning message string in the warnings.warn() call
    to fix the syntax error.

    py/selenium/webdriver/remote/webelement.py [177-181]

     warnings.warn(
    -    "using WebElement.get_attribute() has been deprecated. Please use get_dom_attribute() instead."
    +    "using WebElement.get_attribute() has been deprecated. Please use get_dom_attribute() instead.",
         DeprecationWarning,
         stacklevel=2,
     )
    • Apply this suggestion
    Suggestion importance[1-10]: 10

    Why: The suggestion correctly identifies a syntax error due to a missing comma in the warnings.warn() call, which is crucial for the code to function properly. Adding the comma is necessary to avoid runtime errors, making this a high-impact fix.

    10

    💡 Need additional feedback ? start a PR chat

    @VietND96 VietND96 added the C-py label Nov 1, 2024
    @shbenzer
    Copy link
    Contributor Author

    shbenzer commented Nov 1, 2024

    @VietND96 Failing test is unrelated

    @shbenzer
    Copy link
    Contributor Author

    shbenzer commented Nov 1, 2024

    Just pushed a fix for that flaky test actually #14701

    @shbenzer
    Copy link
    Contributor Author

    shbenzer commented Nov 3, 2024

    @VietND96 now that the bidi_tests.py fix has been merged, could you run the ci workflow again?

    @AutomatedTester AutomatedTester merged commit bb3053b into SeleniumHQ:trunk Nov 3, 2024
    14 checks passed
    VietND96 added a commit that referenced this pull request Nov 26, 2024
    diemol pushed a commit that referenced this pull request Nov 26, 2024
    …14808)
    
    Revert "[py] Added Deprecation of WebElement.get_attribute() per #13334 (#14675)"
    
    This reverts commit bb3053b.
    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.

    3 participants