Skip to content

[FEAT] Add macOS-specific keys (OPTION, FN) to Keys enum for improved… #15910

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 8 commits into from
Jun 23, 2025

Conversation

manuelsblanco
Copy link
Contributor

@manuelsblanco manuelsblanco commented Jun 18, 2025

User description

🔗 Related Issues

N/A

💥 What does this PR do?

This PR adds the missing macOS-specific symbolic keys OPTION and FN to the Keys enum in org.openqa.selenium. These keys are part of the macOS keyboard layout but were not previously represented in the enum.

🔧 Implementation Notes

  • The new keys use Unicode Private Use Area code points \uE050 and \uE051, consistent with the existing keys.
  • Only symbolic representation is added; these keys are not currently mapped to native behavior or events.

💡 Additional Considerations

  • No documentation changes are needed.
  • No functional or behavioral changes are introduced.
  • The update is internal and platform-agnostic unless extended by WebDriver implementations in the future.

🔄 Types of changes

  • Cleanup (formatting, renaming)
  • Bug fix (backwards compatible)
  • New feature (non-breaking change which adds functionality and tests!)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR Type

Enhancement


Description

• Add macOS-specific OPTION and FN keys to Keys enum
• Use Unicode Private Use Area code points for consistency
• Improve platform-specific keyboard support


Changes walkthrough 📝

Relevant files
Enhancement
Keys.java
Add macOS OPTION and FN keys                                                         

java/src/org/openqa/selenium/Keys.java

• Added OPTION key with Unicode code point \uE050
• Added FN key with
Unicode code point \uE051
• Positioned keys after COMMAND key
definition

+2/-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.
  • 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

    Unicode Collision

    The Unicode code points \uE050 and \uE051 should be verified to not conflict with existing keys or reserved ranges in the WebDriver specification or other Selenium implementations.

    OPTION('\uE050'),
    FN('\uE051'),
    Missing Tests

    New enum values should have corresponding unit tests to verify proper instantiation and behavior, especially since this is marked as a new feature with tests in the PR description.

    OPTION('\uE050'),
    FN('\uE051'),

    Copy link
    Contributor

    qodo-merge-pro bot commented Jun 18, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Verify Unicode key code standards
    Suggestion Impact:The suggestion was partially implemented. The commit added TODO comments to verify Unicode values with WebDriver spec for both OPTION and FN keys, exactly as suggested. However, the commit also made additional changes including adding new extended macOS/ChromeDriver keys and reorganizing the code structure.

    code diff:

    +  OPTION('\uE050'), // TODO: verify Unicode value with WebDriver spec
    +  FN('\uE051'),     // TODO: verify Unicode value with WebDriver spec

    The Unicode code points \uE050 and \uE051 appear to be in the Private Use Area
    which may not be standardized across WebDriver implementations. Consider using
    established WebDriver protocol key codes or verify these values align with W3C
    WebDriver specification for macOS keys.

    java/src/org/openqa/selenium/Keys.java [101-102]

    -OPTION('\uE050'),
    -FN('\uE051'),
    +OPTION('\uE050'), // TODO: Verify Unicode value with WebDriver spec
    +FN('\uE051'),     // TODO: Verify Unicode value with WebDriver spec

    [Suggestion processed]

    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly identifies that the new Unicode values \uE050 and \uE051 are in the Private Use Area. This raises a valid concern about standardization and potential inconsistencies across different WebDriver implementations, which is a crucial consideration for a library like Selenium.

    Medium
    • Update

    @selenium-ci selenium-ci added the C-java Java Bindings label Jun 18, 2025
    …COMMAND) follow conventions already in use by ChromeDriver and allow for more accurate key simulations. While not currently in the W3C WebDriver specification, they represent a practical standard used in the field.
    @AutomatedTester
    Copy link
    Member

    Can you explain why you're deleting documentation?

           - Added RIGHT_SHIFT, RIGHT_CONTROL, RIGHT_ALT, and RIGHT_COMMAND using Unicode PUA codes observed in ChromeDriver.
           - Included symbolic macOS keys OPTION and FN, marked with TODO comments for future validation against W3C WebDriver spec.
           - Updated class-level Javadoc to clarify the role of PUA mappings and their interoperability considerations.
    
           These additions improve platform representation and lay the groundwork for consistent macOS key handling.
    @manuelsblanco
    Copy link
    Contributor Author

    Can you explain why you're deleting documentation?

    @AutomatedTester you are right, my bad, solved.

    @diemol diemol merged commit f375257 into SeleniumHQ:trunk Jun 23, 2025
    32 checks passed
    @manuelsblanco manuelsblanco deleted the feature/add-macos-keys branch June 23, 2025 20:36
    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