[py] Allow driver path to be set using ENV variables
User description
Thanks for contributing to Selenium! A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines. Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Allows using custom driver paths using ENV variables
Implements the functionality from the Ruby port in commit https://github.com/SeleniumHQ/selenium/commit/7602371488ebd14d2c6d8d980134bff42bbd17e9#diff-076503247734547bc24938fcc3aa2b317890093dae9376e32ac9b1e41b7037f9
Motivation and Context
As explained in https://github.com/SeleniumHQ/selenium/issues/14045 the goal of this PR is to provide users with an alternative option to set the path to their own drivers if they do not want to use selenium manager
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
- [x] I have read the contributing document.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
PS: Thanks to @Animesh-Ghosh and @aguspe for the help 🚀
PR Type
Enhancement, Tests
Description
- Added support for setting custom driver paths using environment variables across multiple drivers (Chrome, Firefox, Edge, IE, Safari).
- Introduced a new parameter
driver_path_env_keyto specify the environment variable key for driver paths. - Implemented
env_pathmethod in theServiceclass to fetch driver paths from environment variables. - Updated service path logic to prioritize environment variable paths over default paths.
- Added tests to verify the functionality of using environment variables for driver paths.
Changes walkthrough 📝
| Relevant files | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Enhancement | 10 files
| ||||||||||||||||||||
| Tests | 2 files
|
💡 PR-Agent usage: Comment
/help "your question"on any pull request to receive relevant information
PR Reviewer Guide 🔍
| ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪ |
| 🧪 PR contains tests |
| 🔒 No security concerns identified |
| ⚡ Key issues to review Potential Bug Code Duplication |
PR Code Suggestions ✨
| Category | Suggestion | Score |
| Best practice |
Add a docstring to the env_path method for better documentationConsider adding a docstring for the py/selenium/webdriver/common/service.py [241-242]
Suggestion importance[1-10]: 9Why: Providing a docstring significantly improves code documentation, helping developers understand the method's purpose and return value, which is crucial for maintainability. | 9 |
| Enhancement |
Add a type hint for the driver_path_env_key parameter in the constructorConsider adding a type hint for the py/selenium/webdriver/common/service.py [50-58]
Suggestion importance[1-10]: 8Why: Adding a type hint enhances code readability and maintainability, making it clear that the parameter is optional and expected to be a string. | 8 |
Rename the environment variable key attribute for better clarity and consistencyConsider using a more descriptive name for the environment variable key attribute. py/selenium/webdriver/common/service.py [73]
Suggestion importance[1-10]: 7Why: The suggestion improves code readability by using a more descriptive and consistent naming convention, which is beneficial for maintainability. | 7 | |
| Maintainability |
Add a comment to explain the fallback mechanism for setting the service pathConsider adding a comment to explain the fallback mechanism when setting the py/selenium/webdriver/chromium/webdriver.py [54]
Suggestion importance[1-10]: 6Why: The comment clarifies the logic behind the fallback mechanism, aiding in code comprehension and future maintenance, though it is not critical. | 6 |
💡 Need additional feedback ? start a PR chat