[py] Modularize Bazel build with per-module targets by titusfortner · Pull Request #17012 · SeleniumHQ/selenium

Add separate py_library targets for each module following Ruby's pattern:
- exceptions: Base exception classes
- remote: Wire protocol and WebDriver commands
- bidi: BiDi protocol support
- common: Shared utilities, actions, selenium-manager, devtools
- support: Wait conditions, event listeners
- chromium: Base for Chrome/Edge
- chrome, edge, firefox, safari, ie, webkitgtk, wpewebkit: Browser drivers

The aggregate :selenium target is preserved for backwards compatibility,
depending on all module targets. This enables:
- Faster incremental builds when editing a single module
- Clear dependency graph between modules
- Future ability for users to depend on subsets (with lazy imports)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update browser test targets to depend on specific modules instead
of the aggregate :selenium target:
- test-chrome → :chrome, :common, :support
- test-firefox → :firefox, :common, :support
- test-edge → :edge, :common, :support
- etc.

This enables faster incremental test builds when only one module
is modified.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@titusfortner

Add missing deps identified in PR review:
- :bidi needs :remote (imports websocket_connection)
- :support needs :common (imports by, alert)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move selenium/__init__.py and selenium/webdriver/__init__.py to the
:exceptions module so lazy imports (e.g., webdriver.ChromeOptions) work
when depending on individual modules like :chrome instead of :selenium.

This fixes integration test failures where tests use lazy import syntax.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@titusfortner

Fixes mypy error about incompatible types in assignment when
handler is assigned different RemoteConnection subclasses.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move remote_firefox_profile_tests.py to firefox/ folder since it's
  Firefox-specific
- Change remote_hub_connection.py to use ArgOptions instead of Firefox
  Options since the test is about SSL cert verification, not Firefox

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

cgoldberg

@titusfortner

Move remote_firefox_profile_tests.py back to remote/ folder where it
belongs - it needs the server fixture which only exists in remote mode.
Exclude it from chrome-remote tests since it's Firefox-specific.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@titusfortner @claude

Use the Driver class from conftest to handle both local and remote
execution. The test now works with both --remote flag and without it.

Move test from remote/ to firefox/ folder since it's testing a
Firefox-specific feature (profiles), not a remote-only feature.

Rename from remote_firefox_profile_tests.py to firefox_profile_tests.py.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@titusfortner

cgoldberg