webdrivers 4.4.1 → 5.0.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: 478610897cf82cc6520b2501b70eddfc75a6cb000d95ec8a451acff865956913
4
- data.tar.gz: ff8db96ce6a0c80df2e12354ace821f755272b385b76b0fa8f60819312132e53
3
+ metadata.gz: f4c9d9a6544732e58eb7a88d34e39b188b5ff658caaa14fbdff15931a69d1e2d
4
+ data.tar.gz: 92a4997e99508bb79374838461cd2fee48591185b271dd6ce170628c51a02c2c
5
5
  SHA512:
6
- metadata.gz: f56a8c5f61d30f1beccf5a2094f32069fe6b7c5ace48b3f626f53ea67da172113e6324c3616337637843cdab103c9c7b3a87d15982943444cf596c79194dc977
7
- data.tar.gz: d461bec3bfaa089881e002f63c10e939cbcdfbc6edace671eb3a4bcfecc82f34298dc60d76a22363d48d3cf6f547e124f140fcbfc158e9e14eae6b3743f3e443
6
+ metadata.gz: fb469a584a66b14097ec87b6a8f2ad30e2cbefdaeef91efd2a50f16ff0451c8a748f8607d53d06ceed3506d61e54ef31b9997e068f9e55dfe9136f8012570234
7
+ data.tar.gz: ed61ff78edd17f205673242eeba0fa76dcb2df9675a7d8dc4c813e8dd056799a44b13c1a10b238eeb36bae96cc188ca20c4edd71aebf9ec48e9a78e613136f17
data/CHANGELOG.md CHANGED
@@ -1,8 +1,48 @@
1
+ # 5.0.0 (2021-10-19)
2
+ * Require Selenium 4+
3
+ * Remove custom Logger and use the one in Selenium 4
4
+
5
+ # 4.7.0 (2021-10-14)
6
+ * Add support for Selenium 4.x #218 (thanks yahonda )
7
+ * Allow Edge on Linux
8
+ * Update required Selenium > 3.141 because of a change in 4.6
9
+ * Require Ruby 2.6+
10
+ * Fix IE downloads with the change in location of assets
11
+
12
+ # 4.6.1 (2021-08-19)
13
+ * Fix bug in IEdriver caused by bad formatting in recent release
14
+
15
+ # 4.6.0 (2021-02-26)
16
+ * Update `Edgedriver` naming to support Selenium 4 beta (([#206](https://github.com/titusfortner/webdrivers/pull/206))
17
+
18
+ # 4.5.0 (2021-01-19)
19
+ * Improve format of README usage section. Thanks, [okuramasafumi](https://github.com/okuramasafumi)!
20
+ * `chromedriver` - Add support for Apple M1 specific builds ([#193](https://github.com/titusfortner/webdrivers/pull/193)). Thanks, [MichaelHoste](https://github.com/MichaelHoste)!
21
+ * `msedgedriver` - Add support for Apple M1 specific builds.
22
+ * `msedgedriver` - Added automatic selection of 32-bit vs 64-bit builds on Windows and WSLv1.
23
+ * When using this gem in WSLv2, Chrome installed on the Linux filesystem will be automatically used ([#196](https://github.com/titusfortner/webdrivers/pull/196)).
24
+ WSLv1 continues to automatically use Chrome from the Windows filesystem though. Thanks, [fabioxgn](https://github.com/fabioxgn)!
25
+ * We'll aim to make the behavior consistent in a future release.
26
+
27
+ ### 4.4.2 (2020-12-29)
28
+ * Use new powershell if available to enhance WSL support ([#176](https://github.com/titusfortner/webdrivers/issues/176),
29
+ [#186](https://github.com/titusfortner/webdrivers/pull/186)). Thanks, [G-Rath](https://github.com/G-Rath) and
30
+ [131](https://github.com/131)!
31
+ * Update rubocop version (development dependency only) ([#178](https://github.com/titusfortner/webdrivers/pull/178)).
32
+ Thanks, [utkarsh2102](https://github.com/utkarsh2102)!
33
+ * Replace `git ls-files` with `dir` in the gemspec for better Debian support ([#179](https://github.com/titusfortner/webdrivers/pull/179),
34
+ [#184](https://github.com/titusfortner/webdrivers/issues/184)).
35
+ Thanks again, [utkarsh2102](https://github.com/utkarsh2102)!
36
+ * Update README with `require: false` when adding gem to Gemfile ([#183](https://github.com/titusfortner/webdrivers/pull/183)).
37
+ * Make WSL detection more generic ([#187](https://github.com/titusfortner/webdrivers/pull/187)).
38
+ [rbclark](https://github.com/rbclark)!
39
+
1
40
  ### 4.4.1 (2020-06-01)
2
41
  * Do not include binstubs used for troubleshooting only. Fixes [#174](https://github.com/titusfortner/webdrivers/issues/174).
3
42
 
4
43
  ### 4.4.0 (2020-05-31)
5
- * Implement support for `chromedriver` in Windows Subsystem for Linux (WSL) v1 ([#172](https://github.com/titusfortner/webdrivers/issues/172)). Thanks G-Rath!
44
+ * Implement support for `chromedriver` in Windows Subsystem for Linux (WSL) v1 ([#172](https://github.com/titusfortner/webdrivers/issues/172)).
45
+ Thanks, [G-Rath](https://github.com/G-Rath)!
6
46
  * Chrome/Edgedriver - Fix [#171](https://github.com/titusfortner/webdrivers/issues/171) by making sure the cached
7
47
  driver build version matches the browser build version before using it.
8
48
  * Chrome/Edgedriver - Driver version check now matches the driver and browser `major.minor.build` versions instead of just
data/LICENSE.txt CHANGED
@@ -1,23 +1,23 @@
1
- (The MIT License)
2
-
3
- Copyright (c) 2017-2019: Titus Fortner
4
- Copyright (c) 2019: Lakshya Kapoor, Thomas Walpole
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining
7
- a copy of this software and associated documentation files (the
8
- 'Software'), to deal in the Software without restriction, including
9
- without limitation the rights to use, copy, modify, merge, publish,
10
- distribute, sublicense, and/or sell copies of the Software, and to
11
- permit persons to whom the Software is furnished to do so, subject to
12
- the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017-2019: Titus Fortner
4
+ Copyright (c) 2019: Lakshya Kapoor, Thomas Walpole
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Webdrivers
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/webdrivers.svg)](https://badge.fury.io/rb/webdrivers)
4
- [![Build status](https://travis-ci.org/titusfortner/webdrivers.svg?branch=master)](https://travis-ci.org/titusfortner/webdrivers)
5
- [![AppVeyor status](https://ci.appveyor.com/api/projects/status/ejh90xqbvkphq4cy/branch/master?svg=true)](https://ci.appveyor.com/project/titusfortner/webdrivers/branch/master)
4
+ ![Tests](https://github.com/titusfortner/webdrivers/workflows/Tests/badge.svg)
6
5
 
7
6
  Run Selenium tests more easily with automatic installation and updates for all supported webdrivers.
8
7
 
@@ -15,13 +14,16 @@ Run Selenium tests more easily with automatic installation and updates for all s
15
14
  * [IEDriverServer](https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver)
16
15
  * [msedgedriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/)
17
16
 
18
- Works on macOS, Linux, Windows, and Windows Subsystem for Linux (WSL) v1.
17
+ Works on macOS, Linux, Windows, and Windows Subsystem for Linux (WSL) v1 and v2. And do see the browser and OS specific
18
+ notes at the bottom.
19
19
 
20
20
  ## Usage
21
21
 
22
22
  In your Gemfile:
23
23
 
24
- `gem 'webdrivers', '~> 4.0'`
24
+ ```ruby
25
+ gem 'webdrivers', '~> 5.0', require: false
26
+ ```
25
27
 
26
28
  In your project:
27
29
 
@@ -194,7 +196,7 @@ The logging level can be configured for debugging purpose:
194
196
  Webdrivers.logger.level = :DEBUG
195
197
  ```
196
198
 
197
- ### Browser Specific Notes
199
+ ### Browser & OS Specific Notes
198
200
 
199
201
  #### Chrome/Chromium
200
202
 
@@ -219,7 +221,7 @@ variable.
219
221
  This is also required if Google Chrome is not installed in its
220
222
  [default location](https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver).
221
223
 
222
- ##### Heroku Users
224
+ #### Chrome on Heroku
223
225
 
224
226
  Follow the specific instructions [here](https://github.com/titusfortner/webdrivers/wiki/Heroku-buildpack-google-chrome) if you're using `heroku-buildpack-google-chrome`.
225
227
 
@@ -231,6 +233,27 @@ section apply to this browser as well.
231
233
 
232
234
  Please note that `msedgedriver` requires `selenium-webdriver` v4.
233
235
 
236
+ #### WSLv1 support
237
+
238
+ While WSLv1 is not designed to run headful applications like Chrome, it can run exes; as such when found to be running
239
+ in WSL, `webdrivers` will use Chrome on the Windows filesystem.
240
+
241
+ It's recommended that you install the new PowerShell (PS7) to avoid [a known issue](https://github.com/microsoft/terminal/issues/367)
242
+ with the console font being changed when calling the old PowerShell (PS5).
243
+
244
+ #### WSLv2 support
245
+
246
+ Webdrivers will detect WSLv2 as running on Linux and use Chrome on the Linux filesystem.
247
+
248
+ WSLv2 doesn't support connecting to host ports out of the box, so it isn't possible to connect to Chromedriver on
249
+ Windows without extra configurations, see: https://github.com/microsoft/WSL/issues/4619. The simplest way to use
250
+ Chromedriver with WSLv2 is to run Chrome headless on Linux.
251
+
252
+ #### Chrome and Edge on Apple M1 (`arm64`)
253
+
254
+ If you're switching from Intel to M1, you'll have to manually delete the existing Intel (`mac64`) driver before the
255
+ M1 (`arm64`) build can be downloaded. Otherwise, you'll get an error: `Bad CPU type in executable - ~/.webdrivers/chromedriver (Errno::E086)`
256
+
234
257
  ## Wiki
235
258
 
236
259
  Please see the [wiki](https://github.com/titusfortner/webdrivers/wiki)
@@ -88,7 +88,7 @@ module Webdrivers
88
88
  end
89
89
 
90
90
  def linux_location
91
- return wsl_location if System.wsl?
91
+ return wsl_location if System.wsl_v1?
92
92
 
93
93
  directories = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin /opt/google/chrome]
94
94
  files = %w[google-chrome chrome chromium chromium-browser]
@@ -104,6 +104,8 @@ module Webdrivers
104
104
  end
105
105
 
106
106
  def win_version(location)
107
+ System.call("pwsh.exe -command \"(Get-ItemProperty '#{location}').VersionInfo.ProductVersion\"")&.strip
108
+ rescue StandardError
107
109
  System.call("powershell.exe \"(Get-ItemProperty '#{location}').VersionInfo.ProductVersion\"")&.strip
108
110
  end
109
111
 
@@ -112,7 +114,7 @@ module Webdrivers
112
114
  end
113
115
 
114
116
  def linux_version(location)
115
- return wsl_version(location) if System.wsl?
117
+ return wsl_version(location) if System.wsl_v1?
116
118
 
117
119
  System.call(location, '--product-version')&.strip
118
120
  end
@@ -73,34 +73,45 @@ module Webdrivers
73
73
  else
74
74
  msg
75
75
  end
76
- rescue NetworkError
77
- "#{msg} A network issue is preventing determination of latest chromedriver release."
76
+ rescue NetworkError
77
+ "#{msg} A network issue is preventing determination of latest chromedriver release."
78
78
  end
79
79
 
80
80
  msg = "#{msg} Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` "\
81
- 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
82
-
81
+ 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
83
82
  Webdrivers.logger.debug msg
84
83
  raise VersionError, msg
85
84
  end
86
85
 
87
86
  def file_name
88
- System.platform == 'win' || System.wsl? ? 'chromedriver.exe' : 'chromedriver'
87
+ System.platform == 'win' || System.wsl_v1? ? 'chromedriver.exe' : 'chromedriver'
89
88
  end
90
89
 
91
- def download_url
92
- return @download_url if @download_url
90
+ def apple_m1_compatible?(driver_version)
91
+ if System.apple_m1_architecture? && driver_version >= normalize_version('87.0.4280.88')
92
+ Webdrivers.logger.debug 'chromedriver version is Apple M1 compatible.'
93
+ return true
94
+ end
95
+
96
+ Webdrivers.logger.debug 'chromedriver version is NOT Apple M1 compatible. Required >= 87.0.4280.88'
97
+ false
98
+ end
93
99
 
94
- version = if required_version == EMPTY_VERSION
95
- latest_version
96
- else
97
- normalize_version(required_version)
98
- end
100
+ def direct_url(driver_version)
101
+ "#{base_url}/#{driver_version}/chromedriver_#{driver_filename(driver_version)}.zip"
102
+ end
99
103
 
100
- file_name = System.platform == 'win' || System.wsl? ? 'win32' : "#{System.platform}64"
101
- url = "#{base_url}/#{version}/chromedriver_#{file_name}.zip"
102
- Webdrivers.logger.debug "chromedriver URL: #{url}"
103
- @download_url = url
104
+ def driver_filename(driver_version)
105
+ if System.platform == 'win' || System.wsl_v1?
106
+ 'win32'
107
+ elsif System.platform == 'linux'
108
+ 'linux64'
109
+ elsif System.platform == 'mac'
110
+ apple_arch = apple_m1_compatible?(driver_version) ? '_m1' : ''
111
+ "mac64#{apple_arch}"
112
+ else
113
+ raise 'Failed to determine driver filename to download for your OS.'
114
+ end
104
115
  end
105
116
 
106
117
  # Returns major.minor.build version from the currently installed chromedriver version
@@ -135,17 +146,4 @@ module Webdrivers
135
146
  end
136
147
  end
137
148
 
138
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
139
- ::Selenium::WebDriver::Chrome::Service.driver_path = proc { ::Webdrivers::Chromedriver.update }
140
- else
141
- # v3.141.0 and lower
142
- module Selenium
143
- module WebDriver
144
- module Chrome
145
- def self.driver_path
146
- @driver_path ||= Webdrivers::Chromedriver.update
147
- end
148
- end
149
- end
150
- end
151
- end
149
+ ::Selenium::WebDriver::Chrome::Service.driver_path = proc { ::Webdrivers::Chromedriver.update }
@@ -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
@@ -118,12 +118,12 @@ module Webdrivers
118
118
 
119
119
  private
120
120
 
121
+ def download_version
122
+ required_version == EMPTY_VERSION ? latest_version : required_version
123
+ end
124
+
121
125
  def download_url
122
- @download_url ||= if required_version == EMPTY_VERSION
123
- downloads[downloads.keys.max]
124
- else
125
- downloads[normalize_version(required_version)]
126
- end
126
+ @download_url ||= direct_url(download_version).tap { |url| Webdrivers.logger.debug "#{file_name} URL: #{url}" }
127
127
  end
128
128
 
129
129
  def exists?
@@ -131,11 +131,7 @@ module Webdrivers
131
131
  end
132
132
 
133
133
  def correct_binary?
134
- current_version == if required_version == EMPTY_VERSION
135
- latest_version
136
- else
137
- normalize_version(required_version)
138
- end
134
+ current_version == download_version
139
135
  rescue ConnectionError, VersionError
140
136
  driver_path if sufficient_binary?
141
137
  end
@@ -24,15 +24,15 @@ module Webdrivers
24
24
  private
25
25
 
26
26
  def user_defined_location
27
- if Selenium::WebDriver::EdgeChrome.path
28
- Webdrivers.logger.debug "Selenium::WebDriver::EdgeChrome.path: #{Selenium::WebDriver::EdgeChrome.path}"
29
- return Selenium::WebDriver::EdgeChrome.path
27
+ if Selenium::WebDriver::Edge.path
28
+ Webdrivers.logger.debug "Selenium::WebDriver::Edge.path: #{Selenium::WebDriver::Edge.path}"
29
+ return Selenium::WebDriver::Edge.path
30
30
  end
31
31
 
32
- return if ENV['WD_EDGE_CHROME_PATH'].nil?
32
+ return if ENV['WD_EDGE_PATH'].nil?
33
33
 
34
- Webdrivers.logger.debug "WD_EDGE_CHROME_PATH: #{ENV['WD_EDGE_CHROME_PATH']}"
35
- ENV['WD_EDGE_CHROME_PATH']
34
+ Webdrivers.logger.debug "WD_EDGE_PATH: #{ENV['WD_EDGE_PATH']}"
35
+ ENV['WD_EDGE_PATH']
36
36
  end
37
37
 
38
38
  def win_location
@@ -69,6 +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
72
83
  raise 'Default location not yet known'
73
84
  end
74
85
 
@@ -26,10 +26,6 @@ module Webdrivers
26
26
  'https://msedgedriver.azureedge.net/'
27
27
  end
28
28
 
29
- def remove
30
- super
31
- end
32
-
33
29
  private
34
30
 
35
31
  def latest_point_release(version)
@@ -58,8 +54,8 @@ module Webdrivers
58
54
  else
59
55
  msg
60
56
  end
61
- rescue NetworkError
62
- "#{msg} A network issue is preventing determination of latest msedgedriver release."
57
+ rescue NetworkError
58
+ "#{msg} A network issue is preventing determination of latest msedgedriver release."
63
59
  end
64
60
 
65
61
  "#{msg} Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` "\
@@ -70,37 +66,39 @@ module Webdrivers
70
66
  System.platform == 'win' ? 'msedgedriver.exe' : 'msedgedriver'
71
67
  end
72
68
 
73
- def download_url
74
- return @download_url if @download_url
69
+ def apple_m1_compatible?(driver_version)
70
+ if System.apple_m1_architecture? && driver_version >= normalize_version('87.0.669.0')
71
+ Webdrivers.logger.debug 'msedgedriver version is Apple M1 compatible.'
72
+ return true
73
+ end
75
74
 
76
- version = if required_version == EMPTY_VERSION
77
- latest_version
78
- else
79
- normalize_version(required_version)
80
- end
75
+ Webdrivers.logger.debug 'msedgedriver version is NOT Apple M1 compatible. Required >= 87.0.669.0'
76
+ false
77
+ end
81
78
 
82
- file_name = System.platform == 'win' ? 'win32' : "#{System.platform}64"
83
- url = "#{base_url}/#{version}/edgedriver_#{file_name}.zip"
84
- Webdrivers.logger.debug "msedgedriver URL: #{url}"
85
- @download_url = url
79
+ def linux_compatible?(driver_version)
80
+ System.platform == 'linux' && driver_version >= normalize_version('89.0.731.0')
86
81
  end
87
- end
88
- end
89
- end
90
82
 
91
- if defined? Selenium::WebDriver::EdgeChrome
92
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
93
- ::Selenium::WebDriver::EdgeChrome::Service.driver_path = proc { ::Webdrivers::Edgedriver.update }
94
- else
95
- # v3.141.0 and lower
96
- module Selenium
97
- module WebDriver
98
- module EdgeChrome
99
- def self.driver_path
100
- @driver_path ||= Webdrivers::Edgedriver.update
101
- end
83
+ def driver_filename(driver_version)
84
+ if System.platform == 'win' || System.wsl_v1?
85
+ "win#{System.bitsize}" # 32 or 64-bit
86
+ elsif linux_compatible?(driver_version)
87
+ 'linux64'
88
+ elsif System.platform == 'mac'
89
+ # Determine M1 or Intel architecture
90
+ apple_arch = apple_m1_compatible?(driver_version) ? 'arm' : 'mac'
91
+ "#{apple_arch}64"
92
+ else
93
+ raise 'Failed to determine driver filename to download for your OS.'
102
94
  end
103
95
  end
96
+
97
+ def direct_url(driver_version)
98
+ "#{base_url}/#{driver_version}/edgedriver_#{driver_filename(driver_version)}.zip"
99
+ end
104
100
  end
105
101
  end
106
102
  end
103
+
104
+ ::Selenium::WebDriver::Edge::Service.driver_path = proc { ::Webdrivers::Edgedriver.update }
@@ -42,14 +42,6 @@ module Webdrivers
42
42
  System.platform == 'win' ? 'geckodriver.exe' : 'geckodriver'
43
43
  end
44
44
 
45
- def download_url
46
- @download_url ||= if required_version == EMPTY_VERSION
47
- direct_url(latest_version)
48
- else
49
- direct_url(required_version)
50
- end
51
- end
52
-
53
45
  def direct_url(version)
54
46
  "#{base_url}/download/v#{version}/geckodriver-v#{version}-#{platform_ext}"
55
47
  end
@@ -68,17 +60,4 @@ module Webdrivers
68
60
  end
69
61
  end
70
62
 
71
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
72
- ::Selenium::WebDriver::Firefox::Service.driver_path = proc { ::Webdrivers::Geckodriver.update }
73
- else
74
- # v3.141.0 and lower
75
- module Selenium
76
- module WebDriver
77
- module Firefox
78
- def self.driver_path
79
- @driver_path ||= Webdrivers::Geckodriver.update
80
- end
81
- end
82
- end
83
- end
84
- end
63
+ ::Selenium::WebDriver::Firefox::Service.driver_path = proc { ::Webdrivers::Geckodriver.update }
@@ -34,7 +34,7 @@ module Webdrivers
34
34
  #
35
35
  # @return [String]
36
36
  def base_url
37
- 'https://selenium-release.storage.googleapis.com/'
37
+ 'https://api.github.com/repos/seleniumhq/selenium/releases'
38
38
  end
39
39
 
40
40
  private
@@ -43,32 +43,26 @@ module Webdrivers
43
43
  'IEDriverServer.exe'
44
44
  end
45
45
 
46
+ def direct_url(version)
47
+ downloads[version]
48
+ end
49
+
46
50
  def downloads
47
- doc = Nokogiri::XML.parse(Network.get(base_url))
48
- items = doc.css('Key').collect(&:text)
49
- items.select! { |item| item.include?('IEDriverServer_Win32') }
50
- ds = items.each_with_object({}) do |item, hash|
51
- key = normalize_version item[/([^_]+)\.zip/, 1]
52
- hash[key] = "#{base_url}#{item}"
51
+ ds = download_manifest.each_with_object({}) do |item, hash|
52
+ version = normalize_version item['name'][/\.?([^_]+)\.zip/, 1]
53
+ hash[version] = item['browser_download_url']
53
54
  end
54
55
  Webdrivers.logger.debug "Versions now located on downloads site: #{ds.keys}"
55
56
  ds
56
57
  end
57
- end
58
- end
59
- end
60
58
 
61
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
62
- ::Selenium::WebDriver::IE::Service.driver_path = proc { ::Webdrivers::IEdriver.update }
63
- else
64
- # v3.141.0 and lower
65
- module Selenium
66
- module WebDriver
67
- module IE
68
- def self.driver_path
69
- @driver_path ||= Webdrivers::IEdriver.update
70
- end
59
+ def download_manifest
60
+ json = Network.get(base_url)
61
+ all_assets = JSON.parse(json).map { |release| release['assets'] }.flatten
62
+ all_assets.select { |asset| asset['name'].include?('IEDriverServer_Win32') }
71
63
  end
72
64
  end
73
65
  end
74
66
  end
67
+
68
+ ::Selenium::WebDriver::IE::Service.driver_path = proc { ::Webdrivers::IEdriver.update }
@@ -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