-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[py][bidi]: Implement low-level API for Input BiDi module #16049
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
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the BiDi INPUT module for Python WebDriver bindings, providing low-level API access to the W3C WebDriver BiDi input specification. The implementation adds comprehensive input action support including keyboard, pointer, and wheel interactions, plus file dialog event handling.
Key changes include:
- Implementation of all BiDi input commands (perform_actions, release_actions, set_files)
- Support for keyboard, pointer, and wheel input sources with proper action sequences
- File dialog event handling with add/remove handler functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
File | Description |
---|---|
py/selenium/webdriver/common/bidi/input.py |
Core implementation of BiDi input module with action classes, source actions, and Input class |
py/selenium/webdriver/remote/webdriver.py |
Integration of input module as a property in WebDriver class |
py/test/selenium/webdriver/common/bidi_input_tests.py |
Comprehensive test suite covering all input functionality |
raise ValueError("tangential_pressure must be between 0.0 and 1.0") | ||
if not (0 <= self.twist <= 359): | ||
raise ValueError("twist must be between 0 and 359") | ||
if not (0.0 <= self.altitude_angle <= 1.5707963267948966): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 1.5707963267948966 (π/2) should be replaced with a named constant or import from the math module (math.pi/2) for better readability and maintainability.
if not (0.0 <= self.altitude_angle <= 1.5707963267948966): | |
if not (0.0 <= self.altitude_angle <= math.pi / 2): |
Copilot uses AI. Check for mistakes.
raise ValueError("twist must be between 0 and 359") | ||
if not (0.0 <= self.altitude_angle <= 1.5707963267948966): | ||
raise ValueError("altitude_angle must be between 0.0 and π/2") | ||
if not (0.0 <= self.azimuth_angle <= 6.283185307179586): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 6.283185307179586 (2π) should be replaced with a named constant or import from the math module (2 * math.pi) for better readability and maintainability.
if not (0.0 <= self.azimuth_angle <= 6.283185307179586): | |
if not (0.0 <= self.azimuth_angle <= 2 * math.pi): |
Copilot uses AI. Check for mistakes.
button = driver.find_element(By.ID, "clickField") | ||
|
||
# Get element reference for BiDi | ||
element_id = button._id # This gets the internal element ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing the private attribute _id
directly indicates potential API design issues. Consider providing a public method to get the element ID for BiDi operations.
element_id = button._id # This gets the internal element ID | |
element_id = button.get_element_id() # Use public method to get the element ID |
Copilot uses AI. Check for mistakes.
|
||
try: | ||
# Get element reference for BiDi | ||
element_id = upload_element._id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing the private attribute _id
directly indicates potential API design issues. Consider providing a public method to get the element ID for BiDi operations.
element_id = upload_element._id | |
element_id = upload_element.get_element_id() |
Copilot uses AI. Check for mistakes.
|
||
try: | ||
# Get element reference for BiDi | ||
element_id = upload_element._id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing the private attribute _id
directly indicates potential API design issues. Consider providing a public method to get the element ID for BiDi operations.
element_id = upload_element._id | |
element_id = upload_element.get_element_id() |
Copilot uses AI. Check for mistakes.
🔗 Related Issues
💥 What does this PR do?
Adds the BiDi INPUT module for the python bindings - https://w3c.github.io/webdriver-bidi/#module-input
🔧 Implementation Notes
The PR adds 3 commands and 1 event (
input.fileDialogOpened
).Commands:
perform_actions
release_actions
set_files
Event handlers:
add_file_dialog_handler
remove_file_dialog_handler
💡 Additional Considerations
🔄 Types of changes