-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] Simplify DriverService and DriverFinder
#15028
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
| } | ||
|
|
||
| paths.Add(DriverPathKey, driverPath); | ||
| paths.Add(BrowserPathKey, browserPath); |
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.
Best to add both after exceptions, because paths is a shared state which can be corrupted if used wrong.
| DriverServiceExecutableName = Path.GetFileName(fullServicePath); | ||
| if (searchForBrowserPath && finder.TryGetBrowserPath(out string browserPath)) | ||
| { | ||
| options.BinaryLocation = browserPath; |
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.
Setting binary location for IE is not supported (at runtime).
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.
I have the bool searchForBrowserPath set to false on IE and Safari, so this should not be a problem. https://github.com/SeleniumHQ/selenium/pull/15028/files#diff-628f59035c50241ea1a690b5e923fccb569486eea8d138a6a1c08b9bbf78258dR145
|
@RenderMichael @nvborisenko will this be merged or should we close it? |
|
This is something from minor priority box. Personally I don't like the idea to introduce flags in constructors. Up to Mike, please re-evaluate it and go ahead. |
|
This seemed like a nice and simple code deduplication. I don’t have strong opinions about the code being this way vs. the current duplication. Since there’s pushback, I’ll close this. |
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
Removes code duplication by consolidating
GenerateDriverServiceCommandExecutorinto an instance method onDriverService. Also addsTry*method toDriverFinderto simplify lookups.Motivation and Context
Some quick code cleanup opportunity I noticed.
Types of changes
Checklist
PR Type
Enhancement
Description
Consolidated
GenerateDriverServiceCommandExecutorintoDriverServiceasCreateCommandExecutor.Simplified driver initialization across multiple driver classes.
Enhanced
DriverFinderwith nullability, error handling, and aTryGetBrowserPathmethod.Improved code readability and reduced duplication in driver service handling.
Changes walkthrough 📝
ChromiumDriver.cs
Simplified ChromiumDriver initialization.dotnet/src/webdriver/Chromium/ChromiumDriver.cs
GenerateDriverServiceCommandExecutorwithCreateCommandExecutor.DriverFinder.cs
Enhanced DriverFinder with nullability and new methods.dotnet/src/webdriver/DriverFinder.cs
TryGetBrowserPathmethod for safer browser path retrieval.BinaryPathsfor better readability and caching.DriverService.cs
Centralized command executor creation in DriverService.dotnet/src/webdriver/DriverService.cs
CreateCommandExecutormethod to centralize command executorcreation.
DriverService.FirefoxDriver.cs
Simplified FirefoxDriver initialization.dotnet/src/webdriver/Firefox/FirefoxDriver.cs
GenerateDriverServiceCommandExecutorwithCreateCommandExecutor.InternetExplorerDriver.cs
Simplified InternetExplorerDriver initialization.dotnet/src/webdriver/IE/InternetExplorerDriver.cs
GenerateDriverServiceCommandExecutorwithCreateCommandExecutor.SafariDriver.cs
Simplified SafariDriver initialization.dotnet/src/webdriver/Safari/SafariDriver.cs
GenerateDriverServiceCommandExecutorwithCreateCommandExecutor.