-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
[rb] fix using environment variables to set drivers #17571
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,6 @@ def driver_path=(path) | |
| def initialize(path: nil, port: nil, log: nil, args: nil) | ||
| port ||= self.class::DEFAULT_PORT | ||
| args ||= [] | ||
| path ||= env_path | ||
|
|
||
| @executable_path = path | ||
| @host = Platform.localhost | ||
|
|
@@ -88,18 +87,14 @@ def initialize(path: nil, port: nil, log: nil, args: nil) | |
| end | ||
|
|
||
| def launch | ||
| @executable_path ||= env_path || DriverFinder.new(nil, self).driver_path | ||
| @executable_path ||= DriverFinder.new(nil, self).driver_path | ||
| ServiceManager.new(self).tap(&:start) | ||
| end | ||
|
|
||
| def shutdown_supported | ||
| self.class::SHUTDOWN_SUPPORTED | ||
| end | ||
|
|
||
| def env_path | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. service#env_path removed Selenium::WebDriver::Service#env_path was removed without a deprecation path, which is a breaking change for callers and leaves the RBI/RBS contract inconsistent with the runtime implementation. This can trigger runtime NoMethodError for existing consumers and also break RBS/Steep validation during upgrades. Agent Prompt
|
||
| ENV.fetch(self.class::DRIVER_PATH_ENV_KEY, nil) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def warn_driver_log_override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,6 @@ def technology_preview | |
| end | ||
|
|
||
| def technology_preview! | ||
| Service.driver_path = technology_preview | ||
| @use_technology_preview = true | ||
| end | ||
|
|
||
|
|
@@ -47,11 +46,7 @@ def path=(path) | |
| end | ||
|
|
||
| def path | ||
| @path ||= '/Applications/Safari.app/Contents/MacOS/Safari' | ||
| return @path if File.file?(@path) && File.executable?(@path) | ||
| raise Error::WebDriverError, 'Safari is only supported on Mac' unless Platform.os.mac? | ||
|
|
||
| raise Error::WebDriverError, 'Unable to find Safari' | ||
| @path ||= nil | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. safari.path now nil Selenium::WebDriver::Safari.path now defaults to nil, removing the previous behavior of providing/validating a default Safari binary path and raising actionable errors. This is a user-visible behavior change that can break callers relying on a non-nil default or on the earlier deterministic exceptions. Agent Prompt
|
||
| end | ||
| end | ||
| end # Safari | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,8 @@ class Options < WebDriver::Options | |
| # @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari | ||
| CAPABILITIES = {automatic_inspection: 'safari:automaticInspection', | ||
| automatic_profiling: 'safari:automaticProfiling'}.freeze | ||
| BROWSER = Selenium::WebDriver::Safari.technology_preview? ? 'Safari Technology Preview' : 'safari' | ||
| BROWSER = 'safari' | ||
| TECHNOLOGY_PREVIEW = 'Safari Technology Preview' | ||
|
|
||
| def add_option(name, value = nil) | ||
| key = name.is_a?(Hash) ? name.keys.first : name | ||
|
|
@@ -35,9 +36,8 @@ def add_option(name, value = nil) | |
| super | ||
| end | ||
|
|
||
| def as_json(*) | ||
| @options[:browser_name] = Safari.technology_preview? ? 'Safari Technology Preview' : 'safari' | ||
| super | ||
| def browser_name | ||
| @options[:browser_name] = Safari.technology_preview? ? TECHNOLOGY_PREVIEW : BROWSER | ||
|
Comment on lines
+39
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Missing safari::options#browser_name= Defining Safari::Options#browser_name prevents the base Options.set_capabilities from generating the standard browser_name= writer, breaking API compatibility for consumers who set W3C capabilities via the normal setter. It also forces a computed value on every read, making overrides impossible and potentially changing downstream capability payloads. Agent Prompt
Comment on lines
+39
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Safari tp browsername not set Safari::Options#browser_name now mutates @options[:browser_name], but the driver creation path serializes capabilities via options.as_json without ever calling browser_name, so browserName remains the initialize default 'safari' even when Safari.technology_preview! is enabled. This breaks the Safari Technology Preview flow that expects browser_name to be `'Safari Technology Preview'` when the flag is set before or after options are created. Agent Prompt
|
||
| end | ||
| end # Options | ||
| end # Safari | ||
|
|
||
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.
2. Env var service init regression
🐞 Bug≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools