[rb] Update Chrome/Edge args for test environment by cgoldberg · Pull Request #16376 · SeleniumHQ/selenium
PR Code Suggestions ✨
Explore these optional code suggestions:
| Category | Suggestion | Impact |
| Learned best practice |
Avoid mutable default argumentsDo not use a mutable default array for rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb [273-280] -def chrome_options(args: [], **opts) +def chrome_options(args: nil, **opts) + args = (args || []).dup opts[:browser_version] = 'stable' if WebDriver::Platform.windows? opts[:web_socket_url] = true if ENV['WEBDRIVER_BIDI'] && !opts.key?(:web_socket_url) opts[:binary] ||= ENV['CHROME_BINARY'] if ENV.key?('CHROME_BINARY') args << '--headless' if ENV['HEADLESS'] args << '--no-sandbox' unless Platform.windows? WebDriver::Options.chrome(args: args, **opts) end
Suggestion importance[1-10]: 6__ Why: | Low |
Avoid mutable default argumentsReplace the mutable default array for rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb [282-289] -def edge_options(args: [], **opts) +def edge_options(args: nil, **opts) + args = (args || []).dup opts[:browser_version] = 'stable' if WebDriver::Platform.windows? opts[:web_socket_url] = true if ENV['WEBDRIVER_BIDI'] && !opts.key?(:web_socket_url) opts[:binary] ||= ENV['EDGE_BINARY'] if ENV.key?('EDGE_BINARY') args << '--headless' if ENV['HEADLESS'] args << '--no-sandbox' unless Platform.windows? WebDriver::Options.edge(args: args, **opts) end
Suggestion importance[1-10]: 5__ Why: | Low | |
| Possible issue |
Restore a flag for headless stabilityConditionally re-add the rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb [282-289] def edge_options(args: [], **opts)
opts[:browser_version] = 'stable' if WebDriver::Platform.windows?
opts[:web_socket_url] = true if ENV['WEBDRIVER_BIDI'] && !opts.key?(:web_socket_url)
opts[:binary] ||= ENV['EDGE_BINARY'] if ENV.key?('EDGE_BINARY')
- args << '--headless' if ENV['HEADLESS']
+ if ENV['HEADLESS']
+ args << '--headless'
+ args << '--disable-gpu'
+ end
args << '--no-sandbox' unless Platform.windows?
WebDriver::Options.edge(args: args, **opts)
end
Suggestion importance[1-10]: 5__ Why: The suggestion raises a valid point about potential test flakiness by re-adding the | Low |
| ||