[py] Allow ClientConfig when instantiating local webdrivers
User description
🔗 Related Issues
relates to #16282
💥 What does this PR do?
This pull request introduces support for advanced HTTP and WebSocket configuration in all major Selenium WebDriver classes through a new client_config parameter. The change allows users to pass a ClientConfig instance for fine-grained control over connection settings, which takes precedence over legacy parameters like keep_alive. The constructors for Chrome, Edge, Firefox, Internet Explorer, and Safari drivers are updated to accept and normalize this new configuration, ensuring consistent behavior and clear documentation for users.
Major feature: Advanced connection configuration
-
Added an optional
client_configparameter (type:ClientConfig) to the constructors of all major WebDriver classes (chrome,edge,firefox,ie,safari), enabling advanced HTTP/WebSocket settings. The parameter is documented to take precedence overkeep_aliveand other legacy options, and example usage is provided in each class docstring. [1] [2] [3] [4] [5] -
For each driver, the constructor now normalizes
client_configby always settingremote_server_addrto the local driver service URL. If aclient_configis provided by the user, its fields are copied and merged with the service URL, ensuring local drivers always connect to the correct endpoint. [1] [2] [3] [4]
Integration and documentation
-
The new
client_configparameter is passed through to the corresponding remote connection classes (ChromiumRemoteConnection,FirefoxRemoteConnection,SafariRemoteConnection,RemoteConnection), allowing these classes to use the advanced configuration for HTTP and WebSocket connections. [1] [2] [3] [4] -
Imports for
ClientConfigare added to all affected driver files to support the new parameter. [1] [2] [3] [4] [5] -
Docstrings for all affected constructors are updated to clearly explain the purpose and precedence of
client_config, including usage examples for both default and custom configurations. [1] [2] [3] [4] [5]
🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
- New feature (non-breaking change which adds functionality and tests!)
PR Type
Enhancement
Description
-
Added
client_configparameter to all major WebDriver classes -
Enables advanced HTTP/WebSocket configuration for local drivers
-
Normalizes
remote_server_addrto service URL for local drivers -
Comprehensive unit tests for ClientConfig support across drivers
Diagram Walkthrough
flowchart LR
A["WebDriver Classes<br/>Chrome, Edge, Firefox, IE, Safari"] -->|"accept client_config"| B["ClientConfig Instance"]
B -->|"normalize remote_server_addr"| C["Service URL"]
B -->|"preserve user settings"| D["HTTP/WebSocket Config"]
C --> E["RemoteConnection"]
D --> E
E -->|"establish connection"| F["Local Driver Service"]
File Walkthrough
| Relevant files | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Enhancement | 7 files
| ||||||||||||||
| Tests | 6 files
|
https://github.com/iampopovich/selenium/actions/runs/19208403903 The existing tests are passing. I'll study them in more detail soon and write new tests if necessary. @cgoldberg jfyi
@cgoldberg i ran tests here https://github.com/iampopovich/selenium/actions/runs/19274046078
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
| Security Compliance | |
| 🟢 | No security concerns identifiedNo security vulnerabilities detected by AI analysis. Human verification advised for critical code. |
| Ticket Compliance | |
| ⚪ | 🎫 No ticket provided
|
| Codebase Duplication Compliance | |
| ⚪ | Codebase context is not definedFollow the guide to enable codebase context checks. |
| Custom Compliance | |
| 🟢 |
Generic: Meaningful Naming and Self-Documenting CodeObjective: Ensure all identifiers clearly express their purpose and intent, making code Status: Passed
|
Generic: Secure Error HandlingObjective: To prevent the leakage of sensitive system information through error messages while Status: Passed
| |
Generic: Secure Logging PracticesObjective: To ensure logs are useful for debugging and auditing without exposing sensitive Status: Passed
| |
| ⚪ | Generic: Comprehensive Audit TrailsObjective: To create a detailed and reliable record of critical system actions for security analysis Status: Referred Code
|
Generic: Robust Error Handling and Edge Case ManagementObjective: Ensure comprehensive error handling that provides meaningful context and graceful Status: Referred Code
| |
Generic: Security-First Input Validation and Data HandlingObjective: Ensure all data inputs are validated, sanitized, and handled securely to prevent Status: Referred Code
| |
| |
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
PR Code Suggestions ✨
Explore these optional code suggestions:
| Category | Suggestion | Impact |
| High-level |
Refactor duplicated and brittle codeThe Examples:py/selenium/webdriver/chromium/webdriver.py [66-89]
py/selenium/webdriver/firefox/webdriver.py [80-103]
Solution Walkthrough:Before:
After:
Suggestion importance[1-10]: 7__ Why: The suggestion correctly identifies significant code duplication and a brittle, hard-to-maintain implementation for | Medium |
| Possible issue |
✅
| Medium |
| Learned best practice |
✅
| Low |
| ||