Skip to content

[py] add doc support for few exceptions #15913

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 4 commits into from
Jun 20, 2025

Conversation

Delta456
Copy link
Member

@Delta456 Delta456 commented Jun 19, 2025

User description

💥 What does this PR do?

Adds exception messages for errors which have an additional doc on the website for better troubleshooting.

🔄 Types of changes

  • New feature (non-breaking change which adds functionality and tests!)

PR Type

Enhancement


Description

• Add documentation URL support to Python exception classes
• Enhance error messages with troubleshooting links for better user experience
• Implement custom __init__ methods for five exception classes


Changes walkthrough 📝

Relevant files
Enhancement
exceptions.py
Enhanced exception classes with documentation URLs             

py/selenium/common/exceptions.py

• Added custom init methods to five exception classes
• Enhanced
error messages with documentation URLs for troubleshooting

Implemented support message formatting with SUPPORT_MSG and ERROR_URL

• Modified ElementNotVisibleException,
ElementNotInteractableException, ElementClickInterceptedException,
InvalidSessionIdException, and SessionNotCreatedException

+38/-0   

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @selenium-ci selenium-ci added the C-py Python Bindings label Jun 19, 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

    Null Handling

    The code concatenates msg parameter with support message without checking if msg is None, which could result in error messages starting with "None;" when no message is provided

    with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#elementnotvisibleexception"
    Missing Constants

    The code references SUPPORT_MSG and ERROR_URL constants that are not visible in the diff, need to verify these are properly defined and imported in the module

    with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#elementnotvisibleexception"

    Copy link
    Contributor

    qodo-merge-pro bot commented Jun 19, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Handle None message parameter

    Handle the case where msg is None to prevent "None;" from appearing in the error
    message. Add a conditional check before string formatting.

    py/selenium/common/exceptions.py [171]

    -with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#elementnotvisibleexception"
    +with_support = f"{msg or ''}; {SUPPORT_MSG} {ERROR_URL}#elementnotvisibleexception" if msg else f"{SUPPORT_MSG} {ERROR_URL}#elementnotvisibleexception"
    • Apply / Chat
    Suggestion importance[1-10]: 6

    __

    Why: The suggestion correctly points out that if the msg parameter is None, the f-string formatting will result in an undesirable "None;" prefix in the error message. The proposed fix handles this case, improving the quality of the exception message.

    Low
    • Update

    @Delta456 Delta456 requested review from cgoldberg and shbenzer June 19, 2025 14:06
    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

    @AutomatedTester AutomatedTester merged commit 8f65de2 into SeleniumHQ:trunk Jun 20, 2025
    15 of 16 checks passed
    @Delta456 Delta456 deleted the py_exceptions branch June 20, 2025 09:23
    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.

    4 participants