Skip to content

[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

Draft
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

navin772
Copy link
Member

🔗 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:

  1. perform_actions
  2. release_actions
  3. set_files

Event handlers:

  1. add_file_dialog_handler
  2. remove_file_dialog_handler

💡 Additional Considerations

🔄 Types of changes

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

@selenium-ci selenium-ci added C-py Python Bindings B-devtools Includes everything BiDi or Chrome DevTools related labels Jul 14, 2025
@navin772 navin772 requested a review from Copilot July 16, 2025 11:20
Copy link

@Copilot Copilot AI left a 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):
Copy link
Preview

Copilot AI Jul 16, 2025

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.

Suggested change
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):
Copy link
Preview

Copilot AI Jul 16, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jul 16, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jul 16, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jul 16, 2025

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.

Suggested change
element_id = upload_element._id
element_id = upload_element.get_element_id()

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-devtools Includes everything BiDi or Chrome DevTools related C-py Python Bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants