webdrivers 4.3.0 → 4.6.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: 4e86077048e7e1b3964de41e0ba03070ecfea8e7986d50e68cc73b7cff76952f
4
- data.tar.gz: df0102ad80dde4b510aaed556bc0f9e051071facb90cbb2a10f07603fb821b97
3
+ metadata.gz: c31a9a9bcdbe92bc18be8e3175ca852ee58445a442647c0f6f1386b35edacb05
4
+ data.tar.gz: c7f331a4cf2c67e8849e53185228189d11f41d5116b6e0743d09cfedbbefaa3a
5
5
  SHA512:
6
- metadata.gz: ac483fc5a321ca34ea3cdeb3b49f79019d678345173c851a41743c7eadb930a2197530b6a15a5e54fa1369771c256c51091c34f83f3c219dcf16ea3424dc6b9c
7
- data.tar.gz: 8c8601233191ba088aed9637de67bfe4fe766517442b30d9f26bfd696a13bd95734ca62aefc69f67a2810820d1b973b2d957db526a046133cdcaebd330cdbf62
6
+ metadata.gz: 82321bb84a03c26f595bb85a5907742ce4116cbe44b608a2ac27ea5c344452311151271b5eaa3bb7be4f6773fd1882d55e365531638aeed236c497557717a467
7
+ data.tar.gz: 4d65d4764fd7655fce7a040abd3e6b1232c2ca54a8405c9f17ed9bb8005b9ebaf0e979a783da55a32516648fff6cb882eaea79cfc4113dddced022530de43531
data/CHANGELOG.md CHANGED
@@ -1,3 +1,40 @@
1
+ # 4.6.0 (2021-02-26)
2
+ * Update `Edgedriver` naming to support Selenium 4 beta (([#206](https://github.com/titusfortner/webdrivers/pull/206))
3
+
4
+ # 4.5.0 (2021-01-19)
5
+ * Improve format of README usage section. Thanks, [okuramasafumi](https://github.com/okuramasafumi)!
6
+ * `chromedriver` - Add support for Apple M1 specific builds ([#193](https://github.com/titusfortner/webdrivers/pull/193)). Thanks, [MichaelHoste](https://github.com/MichaelHoste)!
7
+ * `msedgedriver` - Add support for Apple M1 specific builds.
8
+ * `msedgedriver` - Added automatic selection of 32-bit vs 64-bit builds on Windows and WSLv1.
9
+ * When using this gem in WSLv2, Chrome installed on the Linux filesystem will be automatically used ([#196](https://github.com/titusfortner/webdrivers/pull/196)).
10
+ WSLv1 continues to automatically use Chrome from the Windows filesystem though. Thanks, [fabioxgn](https://github.com/fabioxgn)!
11
+ * We'll aim to make the behavior consistent in a future release.
12
+
13
+ ### 4.4.2 (2020-12-29)
14
+ * Use new powershell if available to enhance WSL support ([#176](https://github.com/titusfortner/webdrivers/issues/176),
15
+ [#186](https://github.com/titusfortner/webdrivers/pull/186)). Thanks, [G-Rath](https://github.com/G-Rath) and
16
+ [131](https://github.com/131)!
17
+ * Update rubocop version (development dependency only) ([#178](https://github.com/titusfortner/webdrivers/pull/178)).
18
+ Thanks, [utkarsh2102](https://github.com/utkarsh2102)!
19
+ * Replace `git ls-files` with `dir` in the gemspec for better Debian support ([#179](https://github.com/titusfortner/webdrivers/pull/179),
20
+ [#184](https://github.com/titusfortner/webdrivers/issues/184)).
21
+ Thanks again, [utkarsh2102](https://github.com/utkarsh2102)!
22
+ * Update README with `require: false` when adding gem to Gemfile ([#183](https://github.com/titusfortner/webdrivers/pull/183)).
23
+ * Make WSL detection more generic ([#187](https://github.com/titusfortner/webdrivers/pull/187)).
24
+ [rbclark](https://github.com/rbclark)!
25
+
26
+ ### 4.4.1 (2020-06-01)
27
+ * Do not include binstubs used for troubleshooting only. Fixes [#174](https://github.com/titusfortner/webdrivers/issues/174).
28
+
29
+ ### 4.4.0 (2020-05-31)
30
+ * Implement support for `chromedriver` in Windows Subsystem for Linux (WSL) v1 ([#172](https://github.com/titusfortner/webdrivers/issues/172)).
31
+ Thanks, [G-Rath](https://github.com/G-Rath)!
32
+ * Chrome/Edgedriver - Fix [#171](https://github.com/titusfortner/webdrivers/issues/171) by making sure the cached
33
+ driver build version matches the browser build version before using it.
34
+ * Chrome/Edgedriver - Driver version check now matches the driver and browser `major.minor.build` versions instead of just
35
+ the major version to be fully compliant with the `chromedriver` version selection
36
+ [document](https://chromedriver.chromium.org/downloads/version-selection).
37
+
1
38
  ### 4.3.0 (2020-04-14)
2
39
  * Add support for Microsoft Edge (Chromium) stable
3
40
  * Drop support for Ruby < 2.4.0
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,11 +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
 
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
+
18
20
  ## Usage
19
21
 
20
22
  In your Gemfile:
21
23
 
22
- `gem 'webdrivers', '~> 4.0'`
24
+ ```ruby
25
+ gem 'webdrivers', '~> 4.0', require: false
26
+ ```
23
27
 
24
28
  In your project:
25
29
 
@@ -92,10 +96,10 @@ variable. **Only set one to avoid confusion**.
92
96
 
93
97
  ##### Special exception for chromedriver and msedgedriver
94
98
 
95
- Cache time will be respected as long as a driver binary exists and the major versions of
96
- the browser and the driver match. For example, if you update Chrome or Edge to v76 and its driver is
97
- still at v75, `webdrivers` will ignore the cache time and update the driver to make sure you're
98
- using a compatible version.
99
+ Cache time will be respected as long as a driver binary exists and the major.minor.build versions of
100
+ the browser and the driver match. For example, if you update Chrome or Edge to v76.0.123 and its driver is
101
+ still at v76.0.100, `webdrivers` will ignore the cache time and update the driver to make sure you're
102
+ using a compatible build version.
99
103
 
100
104
  ### Proxy
101
105
 
@@ -192,7 +196,7 @@ The logging level can be configured for debugging purpose:
192
196
  Webdrivers.logger.level = :DEBUG
193
197
  ```
194
198
 
195
- ### Browser Specific Notes
199
+ ### Browser & OS Specific Notes
196
200
 
197
201
  #### Chrome/Chromium
198
202
 
@@ -217,7 +221,7 @@ variable.
217
221
  This is also required if Google Chrome is not installed in its
218
222
  [default location](https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver).
219
223
 
220
- ##### Heroku Users
224
+ #### Chrome on Heroku
221
225
 
222
226
  Follow the specific instructions [here](https://github.com/titusfortner/webdrivers/wiki/Heroku-buildpack-google-chrome) if you're using `heroku-buildpack-google-chrome`.
223
227
 
@@ -229,6 +233,27 @@ section apply to this browser as well.
229
233
 
230
234
  Please note that `msedgedriver` requires `selenium-webdriver` v4.
231
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
+
232
257
  ## Wiki
233
258
 
234
259
  Please see the [wiki](https://github.com/titusfortner/webdrivers/wiki)
@@ -50,6 +50,28 @@ module Webdrivers
50
50
  nil
51
51
  end
52
52
 
53
+ def wsl_location
54
+ _, drive, user = ENV['PATH'].match(%r{/([a-z])/Users/([^/:]+)/AppData/}).to_a
55
+
56
+ roots = [
57
+ "#{drive}:\\Users\\#{user}\\AppData\\Local",
58
+ "#{drive}:\\Program Files (x86)",
59
+ "#{drive}:\\Program Files"
60
+ ]
61
+
62
+ directories = %w[Google\\Chrome\\Application Chromium\\Application]
63
+ file = 'chrome.exe'
64
+
65
+ directories.each do |dir|
66
+ roots.each do |root|
67
+ option = System.to_wsl_path("#{root}\\#{dir}\\#{file}")
68
+ return option if File.exist?(option)
69
+ end
70
+ end
71
+
72
+ nil
73
+ end
74
+
53
75
  def mac_location
54
76
  directories = ['', File.expand_path('~')]
55
77
  files = ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
@@ -66,6 +88,8 @@ module Webdrivers
66
88
  end
67
89
 
68
90
  def linux_location
91
+ return wsl_location if System.wsl_v1?
92
+
69
93
  directories = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin /opt/google/chrome]
70
94
  files = %w[google-chrome chrome chromium chromium-browser]
71
95
 
@@ -80,10 +104,18 @@ module Webdrivers
80
104
  end
81
105
 
82
106
  def win_version(location)
83
- System.call("powershell (Get-ItemProperty '#{location}').VersionInfo.ProductVersion")&.strip
107
+ System.call("pwsh.exe -command \"(Get-ItemProperty '#{location}').VersionInfo.ProductVersion\"")&.strip
108
+ rescue StandardError
109
+ System.call("powershell.exe \"(Get-ItemProperty '#{location}').VersionInfo.ProductVersion\"")&.strip
110
+ end
111
+
112
+ def wsl_version(location)
113
+ win_version(System.to_win32_path(location))
84
114
  end
85
115
 
86
116
  def linux_version(location)
117
+ return wsl_version(location) if System.wsl_v1?
118
+
87
119
  System.call(location, '--product-version')&.strip
88
120
  end
89
121
 
@@ -29,9 +29,14 @@ module Webdrivers
29
29
  def latest_version
30
30
  @latest_version ||= begin
31
31
  # Versions before 70 do not have a LATEST_RELEASE file
32
- return normalize_version('2.41') if release_version < normalize_version('70')
32
+ return normalize_version('2.41') if browser_build_version < normalize_version('70')
33
33
 
34
- latest_applicable = with_cache(file_name) { latest_point_release(release_version) }
34
+ # Cache check
35
+ # Cached version should exist and be compatible with the current browser version.
36
+ # Otherwise, fetch the latest compatible driver.
37
+ latest_applicable = with_cache(file_name,
38
+ current_build_version,
39
+ browser_build_version) { latest_point_release(browser_build_version) }
35
40
 
36
41
  Webdrivers.logger.debug "Latest version available: #{latest_applicable}"
37
42
  normalize_version(latest_applicable)
@@ -68,48 +73,84 @@ module Webdrivers
68
73
  else
69
74
  msg
70
75
  end
71
- rescue NetworkError
72
- "#{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."
73
78
  end
74
79
 
75
80
  msg = "#{msg} Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` "\
76
- 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
77
-
81
+ 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
78
82
  Webdrivers.logger.debug msg
79
83
  raise VersionError, msg
80
84
  end
81
85
 
82
86
  def file_name
83
- System.platform == 'win' ? 'chromedriver.exe' : 'chromedriver'
87
+ System.platform == 'win' || System.wsl_v1? ? 'chromedriver.exe' : 'chromedriver'
88
+ end
89
+
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
84
98
  end
85
99
 
86
100
  def download_url
87
101
  return @download_url if @download_url
88
102
 
89
- version = if required_version == EMPTY_VERSION
90
- latest_version
91
- else
92
- normalize_version(required_version)
93
- end
94
-
95
- file_name = System.platform == 'win' ? 'win32' : "#{System.platform}64"
96
- url = "#{base_url}/#{version}/chromedriver_#{file_name}.zip"
103
+ driver_version = if required_version == EMPTY_VERSION
104
+ latest_version
105
+ else
106
+ normalize_version(required_version)
107
+ end
108
+ filename = driver_filename(driver_version)
109
+ url = "#{base_url}/#{driver_version}/chromedriver_#{filename}.zip"
97
110
  Webdrivers.logger.debug "chromedriver URL: #{url}"
98
111
  @download_url = url
99
112
  end
100
113
 
101
- # Returns release version from the currently installed Chrome version
114
+ def driver_filename(driver_version)
115
+ if System.platform == 'win' || System.wsl_v1?
116
+ 'win32'
117
+ elsif System.platform == 'linux'
118
+ 'linux64'
119
+ elsif System.platform == 'mac'
120
+ apple_arch = apple_m1_compatible?(driver_version) ? '_m1' : ''
121
+ "mac64#{apple_arch}"
122
+ else
123
+ raise 'Failed to determine driver filename to download for your OS.'
124
+ end
125
+ end
126
+
127
+ # Returns major.minor.build version from the currently installed chromedriver version
128
+ #
129
+ # @example
130
+ # 73.0.3683.68 (major.minor.build.patch) -> 73.0.3683 (major.minor.build)
131
+ def current_build_version
132
+ build_ver = if current_version.nil? # Driver not found
133
+ nil
134
+ else
135
+ current_version.segments[0..2].join('.')
136
+ end
137
+ normalize_version(build_ver)
138
+ end
139
+
140
+ # Returns major.minor.build version from the currently installed Chrome version
102
141
  #
103
142
  # @example
104
- # 73.0.3683.75 -> 73.0.3683
105
- def release_version
106
- chrome = normalize_version(browser_version)
107
- normalize_version(chrome.segments[0..2].join('.'))
143
+ # 73.0.3683.75 (major.minor.build.patch) -> 73.0.3683 (major.minor.build)
144
+ def browser_build_version
145
+ normalize_version(browser_version.segments[0..2].join('.'))
108
146
  end
147
+ alias chrome_build_version browser_build_version
109
148
 
149
+ # Returns true if an executable driver binary exists
150
+ # and its build version matches the browser build version
110
151
  def sufficient_binary?
111
152
  super && current_version && (current_version < normalize_version('70.0.3538') ||
112
- current_version.segments.first == release_version.segments.first)
153
+ current_build_version == browser_build_version)
113
154
  end
114
155
  end
115
156
  end
@@ -157,9 +157,15 @@ module Webdrivers
157
157
  nil
158
158
  end
159
159
 
160
- def with_cache(file_name)
161
- if System.valid_cache?(file_name)
162
- normalize_version System.cached_version(file_name)
160
+ # Returns cached driver version if cache is still valid and the driver binary exists.
161
+ # Otherwise caches the given version (typically the latest available)
162
+ # In case of Chrome, it also verifies that the driver build and browser build versions are compatible.
163
+ # Example usage: lib/webdrivers/chromedriver.rb:34
164
+ def with_cache(file_name, driver_build = nil, browser_build = nil)
165
+ if System.valid_cache?(file_name) && exists? && (driver_build == browser_build)
166
+ cached_version = System.cached_version(file_name)
167
+ Webdrivers.logger.debug "using cached version as latest: #{cached_version}"
168
+ normalize_version cached_version
163
169
  else
164
170
  version = yield
165
171
  System.cache_version(file_name, version)
@@ -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,17 +66,44 @@ module Webdrivers
70
66
  System.platform == 'win' ? 'msedgedriver.exe' : 'msedgedriver'
71
67
  end
72
68
 
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
74
+
75
+ Webdrivers.logger.debug 'msedgedriver version is NOT Apple M1 compatible. Required >= 87.0.669.0'
76
+ false
77
+ end
78
+
79
+ # def linux_compatible?(driver_version)
80
+ # System.platform == 'linux' && driver_version >= normalize_version('89.0.731.0')
81
+ # end
82
+
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.'
94
+ end
95
+ end
96
+
73
97
  def download_url
74
98
  return @download_url if @download_url
75
99
 
76
- version = if required_version == EMPTY_VERSION
77
- latest_version
78
- else
79
- normalize_version(required_version)
80
- end
81
-
82
- file_name = System.platform == 'win' ? 'win32' : "#{System.platform}64"
83
- url = "#{base_url}/#{version}/edgedriver_#{file_name}.zip"
100
+ driver_version = if required_version == EMPTY_VERSION
101
+ latest_version
102
+ else
103
+ normalize_version(required_version)
104
+ end
105
+ filename = driver_filename(driver_version)
106
+ url = "#{base_url}/#{driver_version}/edgedriver_#{filename}.zip"
84
107
  Webdrivers.logger.debug "msedgedriver URL: #{url}"
85
108
  @download_url = url
86
109
  end
@@ -88,19 +111,4 @@ module Webdrivers
88
111
  end
89
112
  end
90
113
 
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
102
- end
103
- end
104
- end
105
- end
106
- end
114
+ ::Selenium::WebDriver::Edge::Service.driver_path = proc { ::Webdrivers::Edgedriver.update }