webdrivers 5.2.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abf2f2c3590d8497b09a84c7f2b55c2b8c5a5cf5752d178fcd4e4a852c0cfd2c
4
- data.tar.gz: 422f61f2c96fa03e7d4ae5b8564d52058f13334d51ccda07b334805bb2403d6b
3
+ metadata.gz: ea3a67076ea1a3e77e954a92642eed78d0bbcc041dfa0715ff08f911b20e2577
4
+ data.tar.gz: 0bc4ae97ff8d252e5201b79aa24f58d29e1e965948bc4f63bd1923cf84d0accd
5
5
  SHA512:
6
- metadata.gz: dad2443ef52807af22f9780064bb72c226e9101e9997bd787e6ccd3c8a2e161357eb46f476e663a046bee4b9848002f2112a3db5e03a13cd7ca87b564708f54b
7
- data.tar.gz: 809752d1ef3e67e1fe8a5021eeafe3ab93ad1436c1c894ca6765e8f9e739caf8b4b359d2f2ced0ee61cd118cb7492a8281049f60695d2ba0ec5a51d3fa76b1f4
6
+ metadata.gz: c6c95c4b5cc8f198f1df0715574bcf76018e976a311c51e498ef9e3b56277e1a9e45b6255ce721a22e415d546fdef1dcd2b02e864553bdbb1290a06ff3ad8264
7
+ data.tar.gz: d3a8876c9ee4cbe31552946e870775a9fd0aa833db5c9a8843a56ecfd85bbc92d285b9f4237de365fb8bcb1fe837afee6633c9937010442e5c6e47759899645b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 5.3.0 (2023-07-31)
2
+ * Add support for Chrome for Testing drivers ([#237](https://github.com/titusfortner/webdrivers/issues/249), thanks sadahiro-ono)
3
+ * Support is restricted to Selenium 4.0 - 4.10 to encourage people to update to Selenium 4.11
4
+
1
5
  # 5.2.0 (2022-09-29)
2
6
  * `chromedriver` - Fix downloading on M1 macs from version 106.0.5249.61 ([#237](https://github.com/titusfortner/webdrivers/issues/237), thanks jmccure)
3
7
 
data/LICENSE.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2019: Titus Fortner
4
- Copyright (c) 2019: Lakshya Kapoor, Thomas Walpole
3
+ Copyright (c) 2017-2023: Titus Fortner
4
+ Copyright (c) 2019-2023: Lakshya Kapoor, Thomas Walpole
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining
7
7
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -5,6 +5,30 @@
5
5
 
6
6
  Run Selenium tests more easily with automatic installation and updates for all supported webdrivers.
7
7
 
8
+ ## Update: Future of this Project
9
+
10
+ With Google's new [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing/) project,
11
+ and Selenium's new [Selenium Manager](https://www.selenium.dev/documentation/selenium_manager/) feature,
12
+ what is required of this gem has changed.
13
+
14
+ If you can update to to the latest version of Selenium (4.11+), please do so and stop requiring this gem.
15
+ Provide feedback or raise issues to [Selenium Project](https://github.com/SeleniumHQ/selenium/issues/new/choose)
16
+
17
+ If you cannot upgrade to Selenium 4.11, Webdrivers 5.3.0 will continue to support Ruby 2.6+ and Selenium 4.0 - 4.10
18
+
19
+ If you are using an older version of webdrivers gem, and cannot upgrade, you can set
20
+ the required version of chromedriver to v114 (`Webdrivers.required_version = '114.0.5735.90'`) and
21
+ [Disable the build check](https://www.selenium.dev/documentation/webdriver/browsers/chrome/#disabling-build-check).
22
+ This is not guaranteed to continue working and will not receive bug fixes.
23
+
24
+ **Webdrivers 6.0**
25
+ To provide support for Selenium 3 and Ruby < 2.6 a 6.0 version is planned. It requires:
26
+ * Creating a `selenium-manager.gem` based off of https://github.com/SeleniumHQ/selenium/pull/12429
27
+ * Re-implementing this gem to wrap `selenium-manager.gem`
28
+ * Ensuring compatible with older versions of Selenium & Ruby
29
+
30
+ If anyone would like to help get Webdrivers 6 working, please let us know.
31
+
8
32
  ## Description
9
33
 
10
34
  `webdrivers` downloads drivers and directs Selenium to use them. Currently supports:
@@ -63,7 +63,11 @@ module Webdrivers
63
63
  private
64
64
 
65
65
  def latest_point_release(version)
66
- normalize_version(Network.get(URI.join(base_url, "LATEST_RELEASE_#{version}")))
66
+ if version < normalize_version('115')
67
+ return normalize_version(Network.get(URI.join(base_url, "LATEST_RELEASE_#{version}")))
68
+ end
69
+
70
+ latest_patch_version(version)
67
71
  rescue NetworkError
68
72
  msg = "Unable to find latest point release version for #{version}."
69
73
  msg = begin
@@ -78,7 +82,7 @@ module Webdrivers
78
82
  end
79
83
 
80
84
  msg = "#{msg} Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` "\
81
- 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
85
+ 'to a known chromedriver version: https://chromedriver.chromium.org/downloads/version-selection'
82
86
  Webdrivers.logger.debug msg
83
87
  raise VersionError, msg
84
88
  end
@@ -98,15 +102,22 @@ module Webdrivers
98
102
  end
99
103
 
100
104
  def apple_filename(driver_version)
101
- if apple_m1_compatible?(driver_version)
102
- driver_version >= normalize_version('106.0.5249.61') ? 'mac_arm64' : 'mac64_m1'
105
+ unless apple_m1_compatible?(driver_version)
106
+ return driver_version >= normalize_version('115') ? 'mac-x64' : 'mac64'
107
+ end
108
+
109
+ if driver_version < normalize_version('106.0.5249.61')
110
+ 'mac64_m1'
111
+ elsif driver_version < normalize_version('115')
112
+ 'mac_arm64'
103
113
  else
104
- 'mac64'
114
+ 'mac-arm64'
105
115
  end
106
116
  end
107
117
 
108
118
  def direct_url(driver_version)
109
- "#{base_url}/#{driver_version}/chromedriver_#{driver_filename(driver_version)}.zip"
119
+ direct_url_from_api(driver_version) ||
120
+ "#{base_url}/#{driver_version}/chromedriver_#{driver_filename(driver_version)}.zip"
110
121
  end
111
122
 
112
123
  def driver_filename(driver_version)
@@ -141,6 +152,7 @@ module Webdrivers
141
152
  def browser_build_version
142
153
  normalize_version(browser_version.segments[0..2].join('.'))
143
154
  end
155
+
144
156
  alias chrome_build_version browser_build_version
145
157
 
146
158
  # Returns true if an executable driver binary exists
@@ -149,6 +161,33 @@ module Webdrivers
149
161
  super && current_version && (current_version < normalize_version('70.0.3538') ||
150
162
  current_build_version == browser_build_version)
151
163
  end
164
+
165
+ def chrome_for_testing_base_url
166
+ 'https://googlechromelabs.github.io/chrome-for-testing/'
167
+ end
168
+
169
+ def latest_patch_version(driver_version)
170
+ latest_patch_version = URI.join(chrome_for_testing_base_url, 'latest-patch-versions-per-build.json')
171
+ .then { |url| Network.get(url) }
172
+ .then { |res| JSON.parse(res, symbolize_names: true) }
173
+ .then { |json| json.dig(:builds, :"#{driver_version}", :version) }
174
+ .then { |version| version ? normalize_version(version) : nil }
175
+ raise NetworkError unless latest_patch_version
176
+
177
+ latest_patch_version
178
+ end
179
+
180
+ def direct_url_from_api(driver_version)
181
+ return if normalize_version(driver_version) < normalize_version('115')
182
+
183
+ URI.join(chrome_for_testing_base_url, 'known-good-versions-with-downloads.json')
184
+ .then { |url| Network.get(url) }
185
+ .then { |res| JSON.parse(res, symbolize_names: true) }
186
+ .then { |json| json[:versions].find { |e| e[:version] == driver_version.to_s } }
187
+ .then { |json| json.dig(:downloads, :chromedriver) }
188
+ .then { |json| json.find { |e| e[:platform] == driver_filename(driver_version) } }
189
+ .then { |json| json&.dig(:url) }
190
+ end
152
191
  end
153
192
  end
154
193
  end
@@ -127,8 +127,7 @@ module Webdrivers
127
127
  Webdrivers.logger.debug "Decompressing #{filename}"
128
128
 
129
129
  Zip::File.open(filename) do |zip_file|
130
- driver = zip_file.get_entry(driver_name)
131
- f_path = File.join(Dir.pwd, driver.name)
130
+ driver, f_path = driver_and_path(zip_file, driver_name)
132
131
  delete(f_path)
133
132
  FileUtils.mkdir_p(File.dirname(f_path)) unless File.exist?(File.dirname(f_path))
134
133
  zip_file.extract(driver, f_path)
@@ -136,6 +135,18 @@ module Webdrivers
136
135
  driver_name
137
136
  end
138
137
 
138
+ def driver_and_path(zip_file, driver_name)
139
+ driver = zip_file.get_entry(driver_name)
140
+ f_path = File.join(Dir.pwd, driver.name)
141
+
142
+ [driver, f_path]
143
+ rescue Errno::ENOENT
144
+ driver = zip_file.entries.find { |e| File.basename(e.name) == driver_name }
145
+ f_path = File.join(Dir.pwd, File.basename(driver.name))
146
+
147
+ [driver, f_path]
148
+ end
149
+
139
150
  def platform
140
151
  if Selenium::WebDriver::Platform.linux?
141
152
  'linux'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Webdrivers
4
- VERSION = '5.2.0'
4
+ VERSION = '5.3.0'
5
5
  end
@@ -65,8 +65,9 @@ describe Webdrivers::Chromedriver do
65
65
  it 'raises ConnectionError when offline, and no binary exists' do
66
66
  allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
67
67
  allow(chromedriver).to receive(:exists?).and_return(false)
68
+ allow(Webdrivers::ChromeFinder).to receive(:version).and_return('115.0.5790.114')
68
69
 
69
- msg = %r{Can not reach https://chromedriver.storage.googleapis.com}
70
+ msg = %r{Can not reach https://googlechromelabs.github.io/chrome-for-testing}
70
71
  expect { chromedriver.update }.to raise_error(Webdrivers::ConnectionError, msg)
71
72
  end
72
73
  end
@@ -100,8 +101,9 @@ describe Webdrivers::Chromedriver do
100
101
 
101
102
  it 'raises ConnectionError if offline' do
102
103
  allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
104
+ chromedriver.required_version = '115.0.5790.102'
103
105
 
104
- msg = %r{Can not reach https://chromedriver.storage.googleapis.com/}
106
+ msg = %r{Can not reach https://googlechromelabs.github.io/chrome-for-testing}
105
107
  expect { chromedriver.update }.to raise_error(Webdrivers::ConnectionError, msg)
106
108
  end
107
109
  end
@@ -135,6 +137,62 @@ describe Webdrivers::Chromedriver do
135
137
  expect(chromedriver.current_version.version).to eq('72.0.3626.7')
136
138
  end
137
139
  end
140
+
141
+ context 'when using an Apple machine' do
142
+ before do
143
+ allow(Webdrivers::System).to receive(:platform).and_return('mac')
144
+ allow(Webdrivers::System).to receive(:download)
145
+ end
146
+
147
+ context 'with Intel architecture' do
148
+ it 'v114 uses correct suffix' do
149
+ allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(false)
150
+ allow(chromedriver).to receive(:latest_version).and_return(Gem::Version.new('114.0.5735.90'))
151
+ chromedriver.required_version = nil
152
+
153
+ chromedriver.update
154
+ expect(Webdrivers::System).to have_received(:download).with(end_with('_mac64.zip'), anything)
155
+ end
156
+
157
+ it 'v115 uses correct suffix' do
158
+ allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(false)
159
+ allow(chromedriver).to receive(:latest_version).and_return(Gem::Version.new('115.0.5790.102'))
160
+ chromedriver.required_version = nil
161
+
162
+ chromedriver.update
163
+ expect(Webdrivers::System).to have_received(:download).with(end_with('-mac-x64.zip'), anything)
164
+ end
165
+ end
166
+
167
+ context 'with Apple architecture' do
168
+ it 'v106.0.5249.61 uses correct suffix' do
169
+ allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(true)
170
+ allow(chromedriver).to receive(:latest_version).and_return(Gem::Version.new('106.0.5249.61'))
171
+ chromedriver.required_version = nil
172
+
173
+ chromedriver.update
174
+ expect(Webdrivers::System).to have_received(:download).with(end_with('_arm64.zip'), anything)
175
+ end
176
+
177
+ it 'less than v106.0.5249.61 uses correct suffix' do
178
+ allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(true)
179
+ allow(chromedriver).to receive(:latest_version).and_return(Gem::Version.new('106.0.5249.21'))
180
+ chromedriver.required_version = nil
181
+
182
+ chromedriver.update
183
+ expect(Webdrivers::System).to have_received(:download).with(end_with('_mac64_m1.zip'), anything)
184
+ end
185
+
186
+ it 'v115 uses correct suffix' do
187
+ allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(true)
188
+ allow(chromedriver).to receive(:latest_version).and_return(Gem::Version.new('115.0.5790.102'))
189
+ chromedriver.required_version = nil
190
+
191
+ chromedriver.update
192
+ expect(Webdrivers::System).to have_received(:download).with(end_with('-mac-arm64.zip'), anything)
193
+ end
194
+ end
195
+ end
138
196
  end
139
197
 
140
198
  describe '#current_version' do
@@ -172,7 +230,7 @@ describe Webdrivers::Chromedriver do
172
230
  msg = 'Unable to find latest point release version for 999.0.0. '\
173
231
  'You appear to be using a non-production version of Chrome. '\
174
232
  'Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` '\
175
- 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
233
+ 'to a known chromedriver version: https://chromedriver.chromium.org/downloads/version-selection'
176
234
 
177
235
  expect { chromedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
178
236
  end
@@ -181,19 +239,21 @@ describe Webdrivers::Chromedriver do
181
239
  allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('72.0.9999.0000')
182
240
  msg = 'Unable to find latest point release version for 72.0.9999. '\
183
241
  'Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` '\
184
- 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
242
+ 'to a known chromedriver version: https://chromedriver.chromium.org/downloads/version-selection'
185
243
 
186
244
  expect { chromedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
187
245
  end
188
246
 
189
247
  it 'raises ConnectionError when offline' do
190
248
  allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
249
+ allow(Webdrivers::ChromeFinder).to receive(:version).and_return('115.0.5790.114')
191
250
 
192
- msg = %r{^Can not reach https://chromedriver.storage.googleapis.com}
251
+ msg = %r{^Can not reach https://googlechromelabs.github.io/chrome-for-testing}
193
252
  expect { chromedriver.latest_version }.to raise_error(Webdrivers::ConnectionError, msg)
194
253
  end
195
254
 
196
255
  it 'creates cached file' do
256
+ allow(chromedriver).to receive(:latest_patch_version).and_return(nil)
197
257
  allow(Webdrivers::Network).to receive(:get).and_return('71.0.3578.137')
198
258
 
199
259
  chromedriver.latest_version
@@ -224,6 +284,17 @@ describe Webdrivers::Chromedriver do
224
284
  expect(Webdrivers::Network).to have_received(:get)
225
285
  expect(Webdrivers::System).to have_received(:valid_cache?)
226
286
  end
287
+
288
+ it 'call chrome_for_testing if the browser version is greater than 115' do
289
+ allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('115.0.5790.102')
290
+ allow(Webdrivers::Network).to receive(:get).and_return(
291
+ {"builds": {'115.0.5790': {"version": '115.0.5790.102'}}}.to_json
292
+ )
293
+ uri = URI.join('https://googlechromelabs.github.io', '/chrome-for-testing/latest-patch-versions-per-build.json')
294
+
295
+ expect(chromedriver.latest_version).to eq Gem::Version.new('115.0.5790.102')
296
+ expect(Webdrivers::Network).to have_received(:get).with(uri)
297
+ end
227
298
  end
228
299
 
229
300
  describe '#required_version=' do
@@ -95,6 +95,7 @@ describe Webdrivers::Edgedriver do
95
95
  before { allow(edgedriver).to receive(:correct_binary?).and_return(false) }
96
96
 
97
97
  it 'downloads binary' do
98
+ allow(Webdrivers::EdgeFinder).to receive(:version).and_return('115.0.1901.188')
98
99
  edgedriver.update
99
100
 
100
101
  expect(edgedriver.current_version).not_to be_nil
@@ -241,6 +242,7 @@ describe Webdrivers::Edgedriver do
241
242
 
242
243
  describe '#remove' do
243
244
  it 'removes existing edgedriver' do
245
+ allow(Webdrivers::EdgeFinder).to receive(:version).and_return('115.0.1901.188')
244
246
  edgedriver.update
245
247
 
246
248
  edgedriver.remove
@@ -86,10 +86,10 @@ describe Webdrivers::Geckodriver do
86
86
  expect(Webdrivers::System).to have_received(:download).with(url, geckodriver.driver_path)
87
87
  end
88
88
 
89
- it 'does something when a wrong version is supplied' do
89
+ it 'raises error when a wrong version is supplied' do
90
90
  geckodriver.required_version = '0.2.0'
91
91
 
92
- msg = /Net::HTTPServerException: 404 "Not Found"/
92
+ msg = /404 "Not Found"/
93
93
  expect { geckodriver.update }.to raise_error(StandardError, msg)
94
94
  end
95
95
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webdrivers
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
8
8
  - Lakshya Kapoor
9
9
  - Thomas Walpole
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-09-29 00:00:00.000000000 Z
13
+ date: 2023-07-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
@@ -159,6 +159,9 @@ dependencies:
159
159
  - - "~>"
160
160
  - !ruby/object:Gem::Version
161
161
  version: '4.0'
162
+ - - "<"
163
+ - !ruby/object:Gem::Version
164
+ version: '4.11'
162
165
  type: :runtime
163
166
  prerelease: false
164
167
  version_requirements: !ruby/object:Gem::Requirement
@@ -166,6 +169,9 @@ dependencies:
166
169
  - - "~>"
167
170
  - !ruby/object:Gem::Version
168
171
  version: '4.0'
172
+ - - "<"
173
+ - !ruby/object:Gem::Version
174
+ version: '4.11'
169
175
  description: Run Selenium tests more easily with install and updates for all supported
170
176
  webdrivers.
171
177
  email:
@@ -212,9 +218,9 @@ licenses:
212
218
  metadata:
213
219
  bug_tracker_uri: https://github.com/titusfortner/webdrivers/issues
214
220
  changelog_uri: https://github.com/titusfortner/webdrivers/blob/master/CHANGELOG.md
215
- documentation_uri: https://www.rubydoc.info/gems/webdrivers/5.2.0
216
- source_code_uri: https://github.com/titusfortner/webdrivers/tree/v5.2.0
217
- post_install_message:
221
+ documentation_uri: https://www.rubydoc.info/gems/webdrivers/5.3.0
222
+ source_code_uri: https://github.com/titusfortner/webdrivers/tree/v5.3.0
223
+ post_install_message:
218
224
  rdoc_options: []
219
225
  require_paths:
220
226
  - lib
@@ -229,18 +235,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
235
  - !ruby/object:Gem::Version
230
236
  version: '0'
231
237
  requirements: []
232
- rubygems_version: 3.3.22
233
- signing_key:
238
+ rubygems_version: 3.2.33
239
+ signing_key:
234
240
  specification_version: 4
235
241
  summary: Easy download and use of browser drivers.
236
242
  test_files:
237
243
  - spec/spec_helper.rb
238
244
  - spec/webdrivers/chrome_finder_spec.rb
245
+ - spec/webdrivers/chromedriver_spec.rb
239
246
  - spec/webdrivers/edge_finder_spec.rb
240
- - spec/webdrivers/webdrivers_spec.rb
241
- - spec/webdrivers/system_spec.rb
242
247
  - spec/webdrivers/edgedriver_spec.rb
243
- - spec/webdrivers/i_edriver_spec.rb
244
248
  - spec/webdrivers/geckodriver_spec.rb
245
- - spec/webdrivers/chromedriver_spec.rb
249
+ - spec/webdrivers/i_edriver_spec.rb
250
+ - spec/webdrivers/system_spec.rb
251
+ - spec/webdrivers/webdrivers_spec.rb
246
252
  - spec/webdrivers_proxy_support_spec.rb