webdrivers 4.7.0 → 5.1.0

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: 366e7e4f90b5bd54a2f5f1cbe2df6074f6cad56026502ec6d9f0ceddd4a269c8
4
+ data.tar.gz: '09439fb8a5f6e550ab6562891e1b11daa43f13694e21740e8e7141916b02641d'
5
5
  SHA512:
6
- metadata.gz: 727a676f6b025291ecc30fff84b16159820607f4dba0c1216b3c1487f56b5bb4da8679b69b464a5234dc78d872da4b63112b11d60efd3fbb72cfbaf61ea57223
7
- data.tar.gz: 744f5a8173676d02b2f94ff3eda885ec77d47a4e2e04cbfaa04876262e500e906313f6280d0a12e93274ba7f558886a035879d72b0264903fc695c2139b4ca83
6
+ metadata.gz: d7b1a0e9791e985716d7e887c23e7346752218c108ac1bc11c1833c087ecfbf43f5eab718968ab6ddbce1b313740af6d8758a9568cb058edcbe06ae08583a44d
7
+ data.tar.gz: 98fe42f01271e270387795e0dd30ec943d5c0937d413f8ddedf96946ac00b7686a9cf2aee4ce78e52510ff08e2dffb963dd6a282c9abb6267d003a2704f9cfe1
data/CHANGELOG.md CHANGED
@@ -1,8 +1,19 @@
1
+ # 5.1.0 (2022-09-19)
2
+ * Improve error messages (#232, thanks dan-jensen)
3
+ * Fix circular require bug with railtie (#233, thanks amatsuda)
4
+ * Support downloading correct geckodriver on Apple silicon (#234 thanks stephannv)
5
+ * Update linux locations for Chrome to latest chromedriver finder (thanks entretechno-jeremiah)
6
+ * Add support for Microsoft Edge on Linux (#236)
7
+
8
+ # 5.0.0 (2021-10-19)
9
+ * Require Selenium 4+
10
+ * Remove custom Logger and use the one in Selenium 4
11
+
1
12
  # 4.7.0 (2021-10-14)
2
13
  * Add support for Selenium 4.x #218 (thanks yahonda )
3
14
  * Allow Edge on Linux
4
15
  * Update required Selenium > 3.141 because of a change in 4.6
5
- * Require Selenium 2.6+
16
+ * Require Ruby 2.6+
6
17
  * Fix IE downloads with the change in location of assets
7
18
 
8
19
  # 4.6.1 (2021-08-19)
data/README.md CHANGED
@@ -22,7 +22,7 @@ notes at the bottom.
22
22
  In your Gemfile:
23
23
 
24
24
  ```ruby
25
- gem 'webdrivers', '~> 4.0', require: false
25
+ gem 'webdrivers', '~> 5.0', require: false
26
26
  ```
27
27
 
28
28
  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|
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Webdrivers
4
- VERSION = '4.7.0'
4
+ VERSION = '5.1.0'
5
5
  end
@@ -168,8 +168,8 @@ describe Webdrivers::Chromedriver do
168
168
  end
169
169
 
170
170
  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. '\
171
+ allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('999.0.0')
172
+ msg = 'Unable to find latest point release version for 999.0.0. '\
173
173
  'You appear to be using a non-production version of Chrome. '\
174
174
  'Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` '\
175
175
  'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
@@ -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
@@ -128,19 +122,19 @@ describe Webdrivers::Edgedriver do
128
122
 
129
123
  context 'when required version is 0' do
130
124
  it 'downloads the latest version' do
131
- allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('77.0.207.0'))
125
+ allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('98.0.1089.1'))
132
126
  edgedriver.required_version = 0
133
127
  edgedriver.update
134
- expect(edgedriver.current_version.version).to eq('77.0.207.0')
128
+ expect(edgedriver.current_version.version).to eq('98.0.1089.1')
135
129
  end
136
130
  end
137
131
 
138
132
  context 'when required version is nil' do
139
133
  it 'downloads the latest version' do
140
- allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('77.0.207.0'))
134
+ allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('98.0.1089.1'))
141
135
  edgedriver.required_version = nil
142
136
  edgedriver.update
143
- expect(edgedriver.current_version.version).to eq('77.0.207.0')
137
+ expect(edgedriver.current_version.version).to eq('98.0.1089.1')
144
138
  end
145
139
  end
146
140
  end
@@ -170,11 +164,11 @@ describe Webdrivers::Edgedriver do
170
164
  end
171
165
 
172
166
  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. '\
167
+ allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('999.0.0')
168
+ msg = 'Unable to find latest point release version for 999.0.0. '\
175
169
  'You appear to be using a non-production version of Edge. '\
176
170
  'Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` '\
177
- 'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net/'
171
+ 'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net'
178
172
 
179
173
  expect { edgedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
180
174
  end
@@ -183,7 +177,7 @@ describe Webdrivers::Edgedriver do
183
177
  allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('77.0.9999')
184
178
  msg = 'Unable to find latest point release version for 77.0.9999. '\
185
179
  'Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` '\
186
- 'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net/'
180
+ 'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net'
187
181
 
188
182
  expect { edgedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
189
183
  end
@@ -92,6 +92,40 @@ describe Webdrivers::Geckodriver do
92
92
  msg = /Net::HTTPServerException: 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.1.0
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: 2022-09-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
@@ -156,22 +156,16 @@ dependencies:
156
156
  name: selenium-webdriver
157
157
  requirement: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ">"
160
- - !ruby/object:Gem::Version
161
- version: '3.141'
162
- - - "<"
159
+ - - "~>"
163
160
  - !ruby/object:Gem::Version
164
- version: '5.0'
161
+ version: '4.0'
165
162
  type: :runtime
166
163
  prerelease: false
167
164
  version_requirements: !ruby/object:Gem::Requirement
168
165
  requirements:
169
- - - ">"
170
- - !ruby/object:Gem::Version
171
- version: '3.141'
172
- - - "<"
166
+ - - "~>"
173
167
  - !ruby/object:Gem::Version
174
- version: '5.0'
168
+ version: '4.0'
175
169
  description: Run Selenium tests more easily with install and updates for all supported
176
170
  webdrivers.
177
171
  email:
@@ -218,8 +212,8 @@ licenses:
218
212
  metadata:
219
213
  bug_tracker_uri: https://github.com/titusfortner/webdrivers/issues
220
214
  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
215
+ documentation_uri: https://www.rubydoc.info/gems/webdrivers/5.1.0
216
+ source_code_uri: https://github.com/titusfortner/webdrivers/tree/v5.1.0
223
217
  post_install_message:
224
218
  rdoc_options: []
225
219
  require_paths:
@@ -235,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
229
  - !ruby/object:Gem::Version
236
230
  version: '0'
237
231
  requirements: []
238
- rubygems_version: 3.2.22
232
+ rubygems_version: 3.3.7
239
233
  signing_key:
240
234
  specification_version: 4
241
235
  summary: Easy download and use of browser drivers.