-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[dotnet] Simplify DriverService
and DriverFinder
#15028
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
{ | ||
throw new NoSuchDriverException($"The browser path is not a valid file: {browserPath}"); | ||
} | ||
|
||
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
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
GenerateDriverServiceCommandExecutor
into an instance method onDriverService
. Also addsTry*
method toDriverFinder
to simplify lookups.Motivation and Context
Some quick code cleanup opportunity I noticed.
Types of changes
Checklist
PR Type
Enhancement
Description
Consolidated
GenerateDriverServiceCommandExecutor
intoDriverService
asCreateCommandExecutor
.Simplified driver initialization across multiple driver classes.
Enhanced
DriverFinder
with nullability, error handling, and aTryGetBrowserPath
method.Improved code readability and reduced duplication in driver service handling.
Changes walkthrough 📝
ChromiumDriver.cs
Simplified ChromiumDriver initialization.
dotnet/src/webdriver/Chromium/ChromiumDriver.cs
GenerateDriverServiceCommandExecutor
withCreateCommandExecutor
.DriverFinder.cs
Enhanced DriverFinder with nullability and new methods.
dotnet/src/webdriver/DriverFinder.cs
TryGetBrowserPath
method for safer browser path retrieval.BinaryPaths
for better readability and caching.DriverService.cs
Centralized command executor creation in DriverService.
dotnet/src/webdriver/DriverService.cs
CreateCommandExecutor
method to centralize command executorcreation.
DriverService
.FirefoxDriver.cs
Simplified FirefoxDriver initialization.
dotnet/src/webdriver/Firefox/FirefoxDriver.cs
GenerateDriverServiceCommandExecutor
withCreateCommandExecutor
.InternetExplorerDriver.cs
Simplified InternetExplorerDriver initialization.
dotnet/src/webdriver/IE/InternetExplorerDriver.cs
GenerateDriverServiceCommandExecutor
withCreateCommandExecutor
.SafariDriver.cs
Simplified SafariDriver initialization.
dotnet/src/webdriver/Safari/SafariDriver.cs
GenerateDriverServiceCommandExecutor
withCreateCommandExecutor
.