webdrivers 4.7.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 124d154092dc8915735f459f0476c7700e47300bec986e9b88ba214b2db8b92c
4
- data.tar.gz: 9db15712e5227ef9b92db34a7d1714ba9613ca2bd30563b85cf5dbeee5322063
3
+ metadata.gz: 397737ff25d2a4b17d9a89565d8ff3e2dcd8366b3833467dede6e087721e6fdc
4
+ data.tar.gz: 8886caf5f8d78f218b4a73ade8cb002e45fb0d49fb481f318a0e7bf44571eafe
5
5
  SHA512:
6
- metadata.gz: 727a676f6b025291ecc30fff84b16159820607f4dba0c1216b3c1487f56b5bb4da8679b69b464a5234dc78d872da4b63112b11d60efd3fbb72cfbaf61ea57223
7
- data.tar.gz: 744f5a8173676d02b2f94ff3eda885ec77d47a4e2e04cbfaa04876262e500e906313f6280d0a12e93274ba7f558886a035879d72b0264903fc695c2139b4ca83
6
+ metadata.gz: 7c071fe39335199c0c517072b23022c3af03bc720fc5f164cba7631a1eb9606bc6524b94dc14f938f249ecccb13102c9fe6e351ec36e1a7934e075938b2a515d
7
+ data.tar.gz: 6c921a9773de2204c6ec247ecbd30a8c0e298d6f4910036934d73746283936df47bce7f8d22a3ced559c37073db9fab9b6dc2792bab3f48b03faa2daf9820a2d
data/CHANGELOG.md CHANGED
@@ -1,8 +1,29 @@
1
+ # 5.3.1 (2023-07-31)
2
+ * Add post_install_message to explain status of gem
3
+
4
+ # 5.3.0 (2023-07-31)
5
+ * Add support for Chrome for Testing drivers ([#237](https://github.com/titusfortner/webdrivers/issues/249), thanks sadahiro-ono)
6
+ * Support is restricted to Selenium 4.0 - 4.10 to encourage people to update to Selenium 4.11
7
+
8
+ # 5.2.0 (2022-09-29)
9
+ * `chromedriver` - Fix downloading on M1 macs from version 106.0.5249.61 ([#237](https://github.com/titusfortner/webdrivers/issues/237), thanks jmccure)
10
+
11
+ # 5.1.0 (2022-09-19)
12
+ * Improve error messages (#232, thanks dan-jensen)
13
+ * Fix circular require bug with railtie (#233, thanks amatsuda)
14
+ * Support downloading correct geckodriver on Apple silicon (#234 thanks stephannv)
15
+ * Update linux locations for Chrome to latest chromedriver finder (thanks entretechno-jeremiah)
16
+ * Add support for Microsoft Edge on Linux (#236)
17
+
18
+ # 5.0.0 (2021-10-19)
19
+ * Require Selenium 4+
20
+ * Remove custom Logger and use the one in Selenium 4
21
+
1
22
  # 4.7.0 (2021-10-14)
2
23
  * Add support for Selenium 4.x #218 (thanks yahonda )
3
24
  * Allow Edge on Linux
4
25
  * Update required Selenium > 3.141 because of a change in 4.6
5
- * Require Selenium 2.6+
26
+ * Require Ruby 2.6+
6
27
  * Fix IE downloads with the change in location of assets
7
28
 
8
29
  # 4.6.1 (2021-08-19)
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:
@@ -22,7 +46,7 @@ notes at the bottom.
22
46
  In your Gemfile:
23
47
 
24
48
  ```ruby
25
- gem 'webdrivers', '~> 4.0', require: false
49
+ gem 'webdrivers', '~> 5.0', require: false
26
50
  ```
27
51
 
28
52
  In your project:
@@ -8,7 +8,7 @@ module Webdrivers
8
8
  class << self
9
9
  def version
10
10
  version = send("#{System.platform}_version", location)
11
- raise VersionError, 'Failed to find Chrome version.' if version.nil? || version.empty?
11
+ raise VersionError, 'Failed to determine Chrome version.' if version.nil? || version.empty?
12
12
 
13
13
  Webdrivers.logger.debug "Browser version: #{version}"
14
14
  version[/\d+\.\d+\.\d+\.\d+/] # Google Chrome 73.0.3683.75 -> 73.0.3683.75
@@ -18,7 +18,7 @@ module Webdrivers
18
18
  chrome_bin = user_defined_location || send("#{System.platform}_location")
19
19
  return chrome_bin unless chrome_bin.nil?
20
20
 
21
- raise BrowserNotFound, 'Failed to find Chrome binary.'
21
+ raise BrowserNotFound, 'Failed to determine Chrome binary location.'
22
22
  end
23
23
 
24
24
  private
@@ -90,7 +90,17 @@ module Webdrivers
90
90
  def linux_location
91
91
  return wsl_location if System.wsl_v1?
92
92
 
93
- directories = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin /opt/google/chrome]
93
+ directories = %w[
94
+ /usr/local/sbin
95
+ /usr/local/bin
96
+ /usr/sbin
97
+ /usr/bin
98
+ /sbin
99
+ /bin
100
+ /snap/bin
101
+ /opt/google/chrome
102
+ /opt/chromium.org/chromium
103
+ ]
94
104
  files = %w[google-chrome chrome chromium chromium-browser]
95
105
 
96
106
  directories.each do |dir|
@@ -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
@@ -97,8 +101,23 @@ module Webdrivers
97
101
  false
98
102
  end
99
103
 
104
+ def apple_filename(driver_version)
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'
113
+ else
114
+ 'mac-arm64'
115
+ end
116
+ end
117
+
100
118
  def direct_url(driver_version)
101
- "#{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"
102
121
  end
103
122
 
104
123
  def driver_filename(driver_version)
@@ -107,8 +126,7 @@ module Webdrivers
107
126
  elsif System.platform == 'linux'
108
127
  'linux64'
109
128
  elsif System.platform == 'mac'
110
- apple_arch = apple_m1_compatible?(driver_version) ? '_m1' : ''
111
- "mac64#{apple_arch}"
129
+ apple_filename(driver_version)
112
130
  else
113
131
  raise 'Failed to determine driver filename to download for your OS.'
114
132
  end
@@ -134,6 +152,7 @@ module Webdrivers
134
152
  def browser_build_version
135
153
  normalize_version(browser_version.segments[0..2].join('.'))
136
154
  end
155
+
137
156
  alias chrome_build_version browser_build_version
138
157
 
139
158
  # Returns true if an executable driver binary exists
@@ -142,6 +161,33 @@ module Webdrivers
142
161
  super && current_version && (current_version < normalize_version('70.0.3538') ||
143
162
  current_build_version == browser_build_version)
144
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
145
191
  end
146
192
  end
147
193
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rubygems/package'
4
- require 'webdrivers/logger'
5
4
  require 'webdrivers/network'
6
5
  require 'webdrivers/system'
7
6
  require 'selenium-webdriver'
7
+ require 'webdrivers/logger'
8
8
  require 'webdrivers/version'
9
9
 
10
10
  module Webdrivers
@@ -69,18 +69,17 @@ module Webdrivers
69
69
  end
70
70
 
71
71
  def linux_location
72
- # directories = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin /opt/google/chrome]
73
- # files = %w[microsoft-edge] # Based on Microsoft Edge 89.0.760.0 dev
74
- #
75
- # directories.each do |dir|
76
- # files.each do |file|
77
- # option = "#{dir}/#{file}"
78
- # return option if File.exist?(option)
79
- # end
80
- # end
81
- #
82
- # nil
83
- raise 'Default location not yet known'
72
+ directories = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin /opt/microsoft/edge]
73
+ files = %w[microsoft-edge microsoft-edge-beta microsoft-edge-dev]
74
+
75
+ directories.each do |dir|
76
+ files.each do |file|
77
+ option = "#{dir}/#{file}"
78
+ return option if File.exist?(option)
79
+ end
80
+ end
81
+
82
+ nil
84
83
  end
85
84
 
86
85
  def win_version(location)
@@ -22,8 +22,7 @@ module Webdrivers
22
22
  #
23
23
  # @return [String]
24
24
  def base_url
25
- # 'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/'
26
- 'https://msedgedriver.azureedge.net/'
25
+ 'https://msedgedriver.azureedge.net'
27
26
  end
28
27
 
29
28
  private
@@ -76,14 +75,10 @@ module Webdrivers
76
75
  false
77
76
  end
78
77
 
79
- def linux_compatible?(driver_version)
80
- System.platform == 'linux' && driver_version >= normalize_version('89.0.731.0')
81
- end
82
-
83
78
  def driver_filename(driver_version)
84
79
  if System.platform == 'win' || System.wsl_v1?
85
80
  "win#{System.bitsize}" # 32 or 64-bit
86
- elsif linux_compatible?(driver_version)
81
+ elsif System.platform == 'linux'
87
82
  'linux64'
88
83
  elsif System.platform == 'mac'
89
84
  # Determine M1 or Intel architecture
@@ -51,7 +51,7 @@ module Webdrivers
51
51
  when 'linux'
52
52
  "linux#{System.bitsize}.tar.gz"
53
53
  when 'mac'
54
- 'macos.tar.gz'
54
+ System.apple_m1_architecture? ? 'macos-aarch64.tar.gz' : 'macos.tar.gz'
55
55
  when 'win'
56
56
  "win#{System.bitsize}.zip"
57
57
  end
@@ -1,11 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
4
- require 'logger'
5
-
6
- # Code adapted from Selenium Implementation
7
- # https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/common/logger.rb
8
-
9
3
  module Webdrivers
10
4
  #
11
5
  # @example Enable full logging
@@ -18,94 +12,9 @@ module Webdrivers
18
12
  # Webdrivers.logger.info('This is info message')
19
13
  # Webdrivers.logger.warn('This is warning message')
20
14
  #
21
- class Logger
22
- extend Forwardable
23
- include ::Logger::Severity
24
-
25
- def_delegators :@logger, :debug, :debug?,
26
- :info, :info?,
27
- :warn, :warn?,
28
- :error, :error?,
29
- :fatal, :fatal?,
30
- :level
31
-
15
+ class Logger < Selenium::WebDriver::Logger
32
16
  def initialize
33
- @logger = create_logger($stdout)
34
- end
35
-
36
- def output=(io)
37
- # `Logger#reopen` was added in Ruby 2.3
38
- if @logger.respond_to?(:reopen)
39
- @logger.reopen(io)
40
- else
41
- @logger = create_logger(io)
42
- end
43
- end
44
-
45
- #
46
- # For Ruby < 2.3 compatibility
47
- # Based on https://github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L250
48
- #
49
-
50
- def level=(severity)
51
- if severity.is_a?(Integer)
52
- @logger.level = severity
53
- else
54
- case severity.to_s.downcase
55
- when 'debug'
56
- @logger.level = DEBUG
57
- when 'info'
58
- @logger.level = INFO
59
- when 'warn'
60
- @logger.level = WARN
61
- when 'error'
62
- @logger.level = ERROR
63
- when 'fatal'
64
- @logger.level = FATAL
65
- when 'unknown'
66
- @logger.level = UNKNOWN
67
- else
68
- raise ArgumentError, "invalid log level: #{severity}"
69
- end
70
- end
71
- end
72
-
73
- #
74
- # Returns IO object used by logger internally.
75
- #
76
- # Normally, we would have never needed it, but we want to
77
- # use it as IO object for all child processes to ensure their
78
- # output is redirected there.
79
- #
80
- # It is only used in debug level, in other cases output is suppressed.
81
- #
82
- # @api private
83
- #
84
- def io
85
- @logger.instance_variable_get(:@logdev).instance_variable_get(:@dev)
86
- end
87
-
88
- #
89
- # Marks code as deprecated with replacement.
90
- #
91
- # @param [String] old
92
- # @param [String] new
93
- #
94
- def deprecate(old, new)
95
- warn "[DEPRECATION] #{old} is deprecated. Use #{new} instead."
96
- end
97
-
98
- private
99
-
100
- def create_logger(output)
101
- logger = ::Logger.new(output)
102
- logger.progname = 'Webdrivers'
103
- logger.level = ($DEBUG ? DEBUG : WARN)
104
- logger.formatter = proc do |severity, time, progname, msg|
105
- "#{time.strftime('%F %T')} #{severity} #{progname} #{msg}\n"
106
- end
107
-
108
- logger
17
+ super('Webdrivers')
109
18
  end
110
19
  end
111
20
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'webdrivers'
4
3
  require 'rails'
5
4
 
6
5
  module Webdrivers
@@ -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 = '4.7.0'
4
+ VERSION = '5.3.1'
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
@@ -168,11 +226,11 @@ describe Webdrivers::Chromedriver do
168
226
  end
169
227
 
170
228
  it 'raises VersionError for beta version' do
171
- allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('100.0.0')
172
- msg = 'Unable to find latest point release version for 100.0.0. '\
229
+ allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('999.0.0')
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
@@ -5,13 +5,7 @@ require 'spec_helper'
5
5
  describe Webdrivers::EdgeFinder do
6
6
  let(:edge_finder) { described_class }
7
7
 
8
- before(:all) do # rubocop:disable RSpec/BeforeAfterAll
9
- if Selenium::WebDriver::VERSION[0].to_i < 4
10
- skip 'The current selenium-webdriver does not include Chromium based Edge support'
11
- elsif Webdrivers::System.platform == 'linux'
12
- skip 'Edge is not yet supported on Linux'
13
- end
14
- end
8
+ before { skip 'Edge is not yet supported on Linux' if Webdrivers::System.platform == 'linux' }
15
9
 
16
10
  context 'when the user relies on the gem to figure out the location of Edge' do
17
11
  it 'determines the location correctly based on the current OS' do
@@ -5,16 +5,10 @@ require 'spec_helper'
5
5
  describe Webdrivers::Edgedriver do
6
6
  let(:edgedriver) { described_class }
7
7
 
8
- before(:all) do # rubocop:disable RSpec/BeforeAfterAll
9
- if Selenium::WebDriver::VERSION[0].to_i < 4
10
- skip 'The current selenium-webdriver does not include Chromium based Edge support'
11
- elsif Webdrivers::System.platform == 'linux'
12
- skip 'Edge is not yet supported on Linux'
13
- end
8
+ before do
9
+ edgedriver.remove
14
10
  end
15
11
 
16
- before { edgedriver.remove }
17
-
18
12
  describe '#update' do
19
13
  context 'when evaluating #correct_binary?' do
20
14
  it 'does not download when latest version and current version match' do
@@ -101,6 +95,7 @@ describe Webdrivers::Edgedriver do
101
95
  before { allow(edgedriver).to receive(:correct_binary?).and_return(false) }
102
96
 
103
97
  it 'downloads binary' do
98
+ allow(Webdrivers::EdgeFinder).to receive(:version).and_return('115.0.1901.188')
104
99
  edgedriver.update
105
100
 
106
101
  expect(edgedriver.current_version).not_to be_nil
@@ -128,19 +123,19 @@ describe Webdrivers::Edgedriver do
128
123
 
129
124
  context 'when required version is 0' do
130
125
  it 'downloads the latest version' do
131
- allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('77.0.207.0'))
126
+ allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('98.0.1089.1'))
132
127
  edgedriver.required_version = 0
133
128
  edgedriver.update
134
- expect(edgedriver.current_version.version).to eq('77.0.207.0')
129
+ expect(edgedriver.current_version.version).to eq('98.0.1089.1')
135
130
  end
136
131
  end
137
132
 
138
133
  context 'when required version is nil' do
139
134
  it 'downloads the latest version' do
140
- allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('77.0.207.0'))
135
+ allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('98.0.1089.1'))
141
136
  edgedriver.required_version = nil
142
137
  edgedriver.update
143
- expect(edgedriver.current_version.version).to eq('77.0.207.0')
138
+ expect(edgedriver.current_version.version).to eq('98.0.1089.1')
144
139
  end
145
140
  end
146
141
  end
@@ -170,11 +165,11 @@ describe Webdrivers::Edgedriver do
170
165
  end
171
166
 
172
167
  it 'raises VersionError for beta version' do
173
- allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('100.0.0')
174
- msg = 'Unable to find latest point release version for 100.0.0. '\
168
+ allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('999.0.0')
169
+ msg = 'Unable to find latest point release version for 999.0.0. '\
175
170
  'You appear to be using a non-production version of Edge. '\
176
171
  'Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` '\
177
- 'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net/'
172
+ 'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net'
178
173
 
179
174
  expect { edgedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
180
175
  end
@@ -183,7 +178,7 @@ describe Webdrivers::Edgedriver do
183
178
  allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('77.0.9999')
184
179
  msg = 'Unable to find latest point release version for 77.0.9999. '\
185
180
  'Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` '\
186
- 'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net/'
181
+ 'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net'
187
182
 
188
183
  expect { edgedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
189
184
  end
@@ -247,6 +242,7 @@ describe Webdrivers::Edgedriver do
247
242
 
248
243
  describe '#remove' do
249
244
  it 'removes existing edgedriver' do
245
+ allow(Webdrivers::EdgeFinder).to receive(:version).and_return('115.0.1901.188')
250
246
  edgedriver.update
251
247
 
252
248
  edgedriver.remove
@@ -86,12 +86,46 @@ 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
+
96
+ context 'when platform is Apple Sillicon' do
97
+ it 'downloads aarch64 binary' do
98
+ allow(Webdrivers::System).to receive(:platform).and_return('mac')
99
+ allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(true)
100
+ base = 'https://github.com/mozilla/geckodriver/releases/download'
101
+ binary = 'geckodriver-v0.31.0-macos-aarch64.tar.gz'
102
+ url = "#{base}/v0.31.0/#{binary}"
103
+
104
+ allow(Webdrivers::System).to receive(:download).with(url, geckodriver.driver_path)
105
+
106
+ geckodriver.required_version = '0.31.0'
107
+ geckodriver.update
108
+
109
+ expect(Webdrivers::System).to have_received(:download).with(url, geckodriver.driver_path)
110
+ end
111
+ end
112
+
113
+ context 'when platform isn\'t Apple Sillicon' do
114
+ it 'downloads default binary' do
115
+ allow(Webdrivers::System).to receive(:platform).and_return('mac')
116
+ allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(false)
117
+ base = 'https://github.com/mozilla/geckodriver/releases/download'
118
+ binary = 'geckodriver-v0.31.0-macos.tar.gz'
119
+ url = "#{base}/v0.31.0/#{binary}"
120
+
121
+ allow(Webdrivers::System).to receive(:download).with(url, geckodriver.driver_path)
122
+
123
+ geckodriver.required_version = '0.31.0'
124
+ geckodriver.update
125
+
126
+ expect(Webdrivers::System).to have_received(:download).with(url, geckodriver.driver_path)
127
+ end
128
+ end
95
129
  end
96
130
 
97
131
  describe '#current_version' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webdrivers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 5.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-10-14 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
@@ -156,22 +156,22 @@ dependencies:
156
156
  name: selenium-webdriver
157
157
  requirement: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ">"
159
+ - - "~>"
160
160
  - !ruby/object:Gem::Version
161
- version: '3.141'
161
+ version: '4.0'
162
162
  - - "<"
163
163
  - !ruby/object:Gem::Version
164
- version: '5.0'
164
+ version: '4.11'
165
165
  type: :runtime
166
166
  prerelease: false
167
167
  version_requirements: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - ">"
169
+ - - "~>"
170
170
  - !ruby/object:Gem::Version
171
- version: '3.141'
171
+ version: '4.0'
172
172
  - - "<"
173
173
  - !ruby/object:Gem::Version
174
- version: '5.0'
174
+ version: '4.11'
175
175
  description: Run Selenium tests more easily with install and updates for all supported
176
176
  webdrivers.
177
177
  email:
@@ -218,9 +218,18 @@ licenses:
218
218
  metadata:
219
219
  bug_tracker_uri: https://github.com/titusfortner/webdrivers/issues
220
220
  changelog_uri: https://github.com/titusfortner/webdrivers/blob/master/CHANGELOG.md
221
- documentation_uri: https://www.rubydoc.info/gems/webdrivers/4.7.0
222
- source_code_uri: https://github.com/titusfortner/webdrivers/tree/v4.7.0
223
- post_install_message:
221
+ documentation_uri: https://www.rubydoc.info/gems/webdrivers/5.3.1
222
+ source_code_uri: https://github.com/titusfortner/webdrivers/tree/v5.3.1
223
+ post_install_message: |
224
+ Webdrivers gem update options
225
+ *****************************
226
+
227
+ Selenium itself now manages drivers by default: https://www.selenium.dev/documentation/selenium_manager
228
+ * If you are using Ruby 3+ — please update to Selenium 4.11+ and stop requiring this gem
229
+ * If you are using Ruby 2.6+ and Selenium 4.0+ — this version will work for now
230
+ * If you use Ruby < 2.6 or Selenium 3, a 6.0 version of this gem with additional support is planned
231
+
232
+ Restrict your gemfile to "webdrivers", "= 5.3.0" to stop seeing this message
224
233
  rdoc_options: []
225
234
  require_paths:
226
235
  - lib
@@ -235,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
244
  - !ruby/object:Gem::Version
236
245
  version: '0'
237
246
  requirements: []
238
- rubygems_version: 3.2.22
247
+ rubygems_version: 3.2.33
239
248
  signing_key:
240
249
  specification_version: 4
241
250
  summary: Easy download and use of browser drivers.