Skip to content

Commit 7aaae7c

Browse files
committed
[rb] Use pinned browser and driver for remote Grid tests instead of Selenium Manager
1 parent cb1694f commit 7aaae7c

1 file changed

Lines changed: 27 additions & 16 deletions

File tree

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,9 @@ def app_server
9898
end
9999

100100
def remote_server
101-
args = if ENV.key?('CHROMEDRIVER_BINARY')
102-
["-Dwebdriver.chrome.driver=#{rlocation(ENV['CHROMEDRIVER_BINARY'])}"]
103-
elsif ENV.key?('MSEDGEDRIVER_BINARY')
104-
["-Dwebdriver.edge.driver=#{rlocation(ENV['MSEDGEDRIVER_BINARY'])}"]
105-
elsif ENV.key?('GECKODRIVER_BINARY')
106-
["-Dwebdriver.gecko.driver=#{rlocation(ENV['GECKODRIVER_BINARY'])}"]
107-
else
108-
%w[--selenium-manager true]
109-
end
101+
args = driver_path ? %w[--detect-drivers false] : %w[--selenium-manager true]
110102
args += %w[--enable-managed-downloads true]
111-
args += version_stereotype_args unless browser_version == 'stable'
103+
args += driver_configuration if driver_path || browser_version != 'stable'
112104

113105
@remote_server ||= Selenium::Server.new(
114106
remote_server_jar,
@@ -121,12 +113,31 @@ def remote_server
121113
)
122114
end
123115

124-
def version_stereotype_args
125-
stereotype = {browserName: w3c_browser_name, browserVersion: browser_version}.to_json
126-
['--driver-configuration',
127-
"display-name=#{browser} #{browser_version}",
128-
'max-sessions=1',
129-
"stereotype=#{stereotype}"]
116+
def driver_configuration
117+
stereotype = {browserName: w3c_browser_name}
118+
stereotype[:browserVersion] = browser_version unless browser_version == 'stable'
119+
stereotype[options_key] = {binary: browser_path} if driver_path
120+
121+
config = ['--driver-configuration',
122+
"display-name=#{browser} #{browser_version}",
123+
'max-sessions=1']
124+
config << "webdriver-executable=#{driver_path}" if driver_path
125+
config << "stereotype=#{stereotype.to_json}"
126+
config
127+
end
128+
129+
def driver_path
130+
env = {chrome: 'CHROMEDRIVER_BINARY', edge: 'MSEDGEDRIVER_BINARY', firefox: 'GECKODRIVER_BINARY'}[browser]
131+
rlocation(ENV.fetch(env)) if env && ENV.key?(env)
132+
end
133+
134+
def browser_path
135+
env = "#{browser.to_s.upcase}_BINARY"
136+
rlocation(ENV.fetch(env)) if ENV.key?(env)
137+
end
138+
139+
def options_key
140+
{chrome: 'goog:chromeOptions', edge: 'ms:edgeOptions', firefox: 'moz:firefoxOptions'}[browser]
130141
end
131142

132143
def w3c_browser_name

0 commit comments

Comments
 (0)