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

[java]: mark WebElement.getAttribute deprecated #14666

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

Delta456
Copy link
Contributor

@Delta456 Delta456 commented Oct 28, 2024

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

Marks WebElement.getAttribute as deprecated

Motivation and Context

Discussed in #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


Description

  • Deprecated the WebElement.getAttribute method by adding the @Deprecated annotation.
  • This change encourages users to transition to using getDomAttribute and getDomProperty methods introduced in Selenium 4.
  • Aligns with the goal of eventually removing getAttribute in the future.

Changes walkthrough 📝

Relevant files
Enhancement
WebElement.java
Deprecate `getAttribute` method in WebElement interface   

java/src/org/openqa/selenium/WebElement.java

  • Marked the getAttribute method as deprecated.
  • Added @Deprecated annotation to the getAttribute method.
  • +1/-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:

    🎫 Ticket compliance analysis 🔶

    13334 - Partially compliant

    Fully compliant requirements:

    • Deprecate WebElement.getAttribute method

    Not compliant requirements:

    • Encourage users to move to WebElement.getDomAttribute and WebElement.getDomProperty methods
    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Missing Deprecation Message
    The @deprecated annotation should include a message explaining why the method is deprecated and suggesting alternative methods to use.

    Copy link
    Contributor

    qodo-merge-pro bot commented Oct 28, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    ✅ Update method documentation to reflect its deprecated status and provide alternatives
    Suggestion Impact:The Javadoc was updated to mention the method's deprecated status and suggest alternative methods, aligning with the suggestion.

    code diff:

    +   * @deprecated This method is deprecated. Use {@link #getDomProperty(String)} or {@link
    +   *     #getDomAttribute(String)} for more precise attribute retrieval.

    Update the method's Javadoc to mention its deprecated status and suggest alternative
    methods to use.

    java/src/org/openqa/selenium/WebElement.java [163-170]

     /**
      * <p>See <a href="https://w3c.github.io/webdriver/#get-element-attribute">W3C WebDriver
      * specification</a> for more details.
      *
      * @param name The name of the attribute.
      * @return The attribute/property's current value or null if the value is not set.
    + * @deprecated This method is deprecated. Use {@link #getProperty(String)} or {@link #getDomAttribute(String)} for more precise attribute retrieval.
      */
     @Deprecated
     @Nullable String getAttribute(String name);
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Updating the Javadoc to mention the deprecation and suggest alternative methods enhances documentation quality, ensuring developers are informed about the change and can transition smoothly to recommended methods.

    9
    Best practice
    Enhance the deprecation annotation with additional information to guide developers

    Consider adding a reason for the deprecation in the @Deprecated annotation to
    provide more context for developers using this method.

    java/src/org/openqa/selenium/WebElement.java [169-170]

    -@Deprecated
    +@Deprecated(since = "4.x", forRemoval = true, reason = "Use getProperty() or getDomAttribute() for more precise attribute retrieval")
     @Nullable String getAttribute(String name);
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding a reason for deprecation in the @Deprecated annotation provides clarity and guidance for developers, improving code maintainability and usability by suggesting alternatives.

    8

    💡 Need additional feedback ? start a PR chat

    @VietND96 VietND96 requested a review from diemol October 28, 2024 15:53
    @VietND96 VietND96 requested a review from pujagani November 1, 2024 03:38
    Copy link
    Contributor

    @pujagani pujagani left a comment

    Choose a reason for hiding this comment

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

    LGTM. Thank you! @Delta456

    @pujagani pujagani merged commit cd7303c into SeleniumHQ:trunk Nov 5, 2024
    4 checks passed
    @Delta456 Delta456 deleted the attr branch November 6, 2024 10:30
    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.

    4 participants