webdrivers 4.1.2 → 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 +4 -4
- data/CHANGELOG.md +64 -0
- data/README.md +36 -11
- data/lib/webdrivers/chrome_finder.rb +34 -2
- data/lib/webdrivers/chromedriver.rb +56 -38
- data/lib/webdrivers/common.rb +17 -16
- data/lib/webdrivers/edge_finder.rb +22 -7
- data/lib/webdrivers/edgedriver.rb +29 -31
- data/lib/webdrivers/geckodriver.rb +1 -22
- data/lib/webdrivers/iedriver.rb +14 -20
- data/lib/webdrivers/logger.rb +2 -93
- data/lib/webdrivers/network.rb +2 -0
- data/lib/webdrivers/system.rb +39 -2
- data/lib/webdrivers/version.rb +1 -1
- data/spec/webdrivers/chrome_finder_spec.rb +53 -0
- data/spec/webdrivers/chromedriver_spec.rb +14 -9
- data/spec/webdrivers/edge_finder_spec.rb +9 -15
- data/spec/webdrivers/edgedriver_spec.rb +20 -22
- data/spec/webdrivers/geckodriver_spec.rb +7 -8
- data/spec/webdrivers/i_edriver_spec.rb +14 -10
- data/spec/webdrivers/system_spec.rb +79 -0
- data/spec/webdrivers/webdrivers_spec.rb +15 -21
- metadata +46 -48
- data/.github/ISSUE_TEMPLATE.md +0 -16
- data/.gitignore +0 -8
- data/.rubocop.yml +0 -47
- data/.travis.yml +0 -41
- data/Gemfile +0 -6
- data/Rakefile +0 -11
- data/appveyor.yml +0 -45
- data/gemfiles/Gemfile.edge +0 -7
- data/support/install_jruby.ps1 +0 -7
- data/support/install_msedge.ps1 +0 -17
- data/webdrivers.gemspec +0 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4c9d9a6544732e58eb7a88d34e39b188b5ff658caaa14fbdff15931a69d1e2d
|
|
4
|
+
data.tar.gz: 92a4997e99508bb79374838461cd2fee48591185b271dd6ce170628c51a02c2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb469a584a66b14097ec87b6a8f2ad30e2cbefdaeef91efd2a50f16ff0451c8a748f8607d53d06ceed3506d61e54ef31b9997e068f9e55dfe9136f8012570234
|
|
7
|
+
data.tar.gz: ed61ff78edd17f205673242eeba0fa76dcb2df9675a7d8dc4c813e8dd056799a44b13c1a10b238eeb36bae96cc188ca20c4edd71aebf9ec48e9a78e613136f17
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
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
|
+
|
|
40
|
+
### 4.4.1 (2020-06-01)
|
|
41
|
+
* Do not include binstubs used for troubleshooting only. Fixes [#174](https://github.com/titusfortner/webdrivers/issues/174).
|
|
42
|
+
|
|
43
|
+
### 4.4.0 (2020-05-31)
|
|
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)!
|
|
46
|
+
* Chrome/Edgedriver - Fix [#171](https://github.com/titusfortner/webdrivers/issues/171) by making sure the cached
|
|
47
|
+
driver build version matches the browser build version before using it.
|
|
48
|
+
* Chrome/Edgedriver - Driver version check now matches the driver and browser `major.minor.build` versions instead of just
|
|
49
|
+
the major version to be fully compliant with the `chromedriver` version selection
|
|
50
|
+
[document](https://chromedriver.chromium.org/downloads/version-selection).
|
|
51
|
+
|
|
52
|
+
### 4.3.0 (2020-04-14)
|
|
53
|
+
* Add support for Microsoft Edge (Chromium) stable
|
|
54
|
+
* Drop support for Ruby < 2.4.0
|
|
55
|
+
|
|
56
|
+
### 4.2.0 (2019-12-27)
|
|
57
|
+
* Add support for Microsoft Edge (Chromium) Beta releases ([#155](https://github.com/titusfortner/webdrivers/pull/155))
|
|
58
|
+
* Use tilde expansion to resolve user's home directory ([#166](https://github.com/titusfortner/webdrivers/pull/161))
|
|
59
|
+
* Add support for Chromium installed using Snap on Ubuntu ([#163](https://github.com/titusfortner/webdrivers/pull/163)). Thanks Tietew!
|
|
60
|
+
|
|
61
|
+
### 4.1.3 (2019-10-07)
|
|
62
|
+
* Require rubyzip version 1.3.0 or higher to fix [rubyzip#403](https://github.com/rubyzip/rubyzip/pull/403). Thanks rhymes! ([#153](https://github.com/titusfortner/webdrivers/pull/153))
|
|
63
|
+
* Fix a bug where the file deletion confirmation was printed even when there were no files to delete.
|
|
64
|
+
|
|
1
65
|
### 4.1.2 (2019-07-29)
|
|
2
66
|
* Fix a bug related to raising `BrowserNotFound`.
|
|
3
67
|
|
data/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Webdrivers
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/rb/webdrivers)
|
|
4
|
-
|
|
5
|
-
[](https://ci.appveyor.com/project/titusfortner/webdrivers/branch/master)
|
|
4
|
+

|
|
6
5
|
|
|
7
6
|
Run Selenium tests more easily with automatic installation and updates for all supported webdrivers.
|
|
8
7
|
|
|
@@ -13,13 +12,18 @@ Run Selenium tests more easily with automatic installation and updates for all s
|
|
|
13
12
|
* [chromedriver](http://chromedriver.chromium.org/)
|
|
14
13
|
* [geckodriver](https://github.com/mozilla/geckodriver)
|
|
15
14
|
* [IEDriverServer](https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver)
|
|
16
|
-
* [msedgedriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/)
|
|
15
|
+
* [msedgedriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/)
|
|
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.
|
|
17
19
|
|
|
18
20
|
## Usage
|
|
19
21
|
|
|
20
22
|
In your Gemfile:
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
```ruby
|
|
25
|
+
gem 'webdrivers', '~> 5.0', require: false
|
|
26
|
+
```
|
|
23
27
|
|
|
24
28
|
In your project:
|
|
25
29
|
|
|
@@ -68,7 +72,7 @@ Webdrivers::Geckodriver.required_version = '0.23.0'
|
|
|
68
72
|
Webdrivers::IEdriver.required_version = '3.14.0'
|
|
69
73
|
|
|
70
74
|
# Edge (Chromium)
|
|
71
|
-
Webdrivers::Edgedriver.required_version
|
|
75
|
+
Webdrivers::Edgedriver.required_version = '76.0.183.0'
|
|
72
76
|
```
|
|
73
77
|
|
|
74
78
|
You can explicitly trigger the update in your code, but this will happen
|
|
@@ -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
|
|
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
|
-
|
|
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,7 +88,9 @@ module Webdrivers
|
|
|
66
88
|
end
|
|
67
89
|
|
|
68
90
|
def linux_location
|
|
69
|
-
|
|
91
|
+
return wsl_location if System.wsl_v1?
|
|
92
|
+
|
|
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
|
|
|
72
96
|
directories.each do |dir|
|
|
@@ -80,10 +104,18 @@ module Webdrivers
|
|
|
80
104
|
end
|
|
81
105
|
|
|
82
106
|
def win_version(location)
|
|
83
|
-
System.call("
|
|
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
|
|
32
|
+
return normalize_version('2.41') if browser_build_version < normalize_version('70')
|
|
33
33
|
|
|
34
|
-
|
|
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,64 +73,77 @@ module Webdrivers
|
|
|
68
73
|
else
|
|
69
74
|
msg
|
|
70
75
|
end
|
|
71
|
-
|
|
72
|
-
|
|
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'
|
|
84
88
|
end
|
|
85
89
|
|
|
86
|
-
def
|
|
87
|
-
|
|
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
|
|
88
99
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
normalize_version(required_version)
|
|
93
|
-
end
|
|
100
|
+
def direct_url(driver_version)
|
|
101
|
+
"#{base_url}/#{driver_version}/chromedriver_#{driver_filename(driver_version)}.zip"
|
|
102
|
+
end
|
|
94
103
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
99
115
|
end
|
|
100
116
|
|
|
101
|
-
# Returns
|
|
117
|
+
# Returns major.minor.build version from the currently installed chromedriver version
|
|
102
118
|
#
|
|
103
119
|
# @example
|
|
104
|
-
# 73.0.3683.
|
|
105
|
-
def
|
|
106
|
-
|
|
107
|
-
|
|
120
|
+
# 73.0.3683.68 (major.minor.build.patch) -> 73.0.3683 (major.minor.build)
|
|
121
|
+
def current_build_version
|
|
122
|
+
build_ver = if current_version.nil? # Driver not found
|
|
123
|
+
nil
|
|
124
|
+
else
|
|
125
|
+
current_version.segments[0..2].join('.')
|
|
126
|
+
end
|
|
127
|
+
normalize_version(build_ver)
|
|
108
128
|
end
|
|
109
129
|
|
|
130
|
+
# Returns major.minor.build version from the currently installed Chrome version
|
|
131
|
+
#
|
|
132
|
+
# @example
|
|
133
|
+
# 73.0.3683.75 (major.minor.build.patch) -> 73.0.3683 (major.minor.build)
|
|
134
|
+
def browser_build_version
|
|
135
|
+
normalize_version(browser_version.segments[0..2].join('.'))
|
|
136
|
+
end
|
|
137
|
+
alias chrome_build_version browser_build_version
|
|
138
|
+
|
|
139
|
+
# Returns true if an executable driver binary exists
|
|
140
|
+
# and its build version matches the browser build version
|
|
110
141
|
def sufficient_binary?
|
|
111
142
|
super && current_version && (current_version < normalize_version('70.0.3538') ||
|
|
112
|
-
|
|
143
|
+
current_build_version == browser_build_version)
|
|
113
144
|
end
|
|
114
145
|
end
|
|
115
146
|
end
|
|
116
147
|
end
|
|
117
148
|
|
|
118
|
-
|
|
119
|
-
::Selenium::WebDriver::Chrome::Service.driver_path = proc { ::Webdrivers::Chromedriver.update }
|
|
120
|
-
else
|
|
121
|
-
# v3.141.0 and lower
|
|
122
|
-
module Selenium
|
|
123
|
-
module WebDriver
|
|
124
|
-
module Chrome
|
|
125
|
-
def self.driver_path
|
|
126
|
-
@driver_path ||= Webdrivers::Chromedriver.update
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
|
149
|
+
::Selenium::WebDriver::Chrome::Service.driver_path = proc { ::Webdrivers::Chromedriver.update }
|
data/lib/webdrivers/common.rb
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'rubygems/package'
|
|
4
|
-
require 'zip'
|
|
5
|
-
require 'webdrivers/logger'
|
|
6
4
|
require 'webdrivers/network'
|
|
7
5
|
require 'webdrivers/system'
|
|
8
6
|
require 'selenium-webdriver'
|
|
7
|
+
require 'webdrivers/logger'
|
|
9
8
|
require 'webdrivers/version'
|
|
10
9
|
|
|
11
10
|
module Webdrivers
|
|
@@ -22,7 +21,7 @@ module Webdrivers
|
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
DEFAULT_CACHE_TIME = 86_400 # 24 hours
|
|
25
|
-
DEFAULT_INSTALL_DIR = File.expand_path(
|
|
24
|
+
DEFAULT_INSTALL_DIR = File.expand_path('~/.webdrivers')
|
|
26
25
|
|
|
27
26
|
class << self
|
|
28
27
|
attr_accessor :proxy_addr, :proxy_port, :proxy_user, :proxy_pass
|
|
@@ -119,12 +118,12 @@ module Webdrivers
|
|
|
119
118
|
|
|
120
119
|
private
|
|
121
120
|
|
|
121
|
+
def download_version
|
|
122
|
+
required_version == EMPTY_VERSION ? latest_version : required_version
|
|
123
|
+
end
|
|
124
|
+
|
|
122
125
|
def download_url
|
|
123
|
-
@download_url ||=
|
|
124
|
-
downloads[downloads.keys.max]
|
|
125
|
-
else
|
|
126
|
-
downloads[normalize_version(required_version)]
|
|
127
|
-
end
|
|
126
|
+
@download_url ||= direct_url(download_version).tap { |url| Webdrivers.logger.debug "#{file_name} URL: #{url}" }
|
|
128
127
|
end
|
|
129
128
|
|
|
130
129
|
def exists?
|
|
@@ -132,11 +131,7 @@ module Webdrivers
|
|
|
132
131
|
end
|
|
133
132
|
|
|
134
133
|
def correct_binary?
|
|
135
|
-
current_version ==
|
|
136
|
-
latest_version
|
|
137
|
-
else
|
|
138
|
-
normalize_version(required_version)
|
|
139
|
-
end
|
|
134
|
+
current_version == download_version
|
|
140
135
|
rescue ConnectionError, VersionError
|
|
141
136
|
driver_path if sufficient_binary?
|
|
142
137
|
end
|
|
@@ -158,9 +153,15 @@ module Webdrivers
|
|
|
158
153
|
nil
|
|
159
154
|
end
|
|
160
155
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
# Returns cached driver version if cache is still valid and the driver binary exists.
|
|
157
|
+
# Otherwise caches the given version (typically the latest available)
|
|
158
|
+
# In case of Chrome, it also verifies that the driver build and browser build versions are compatible.
|
|
159
|
+
# Example usage: lib/webdrivers/chromedriver.rb:34
|
|
160
|
+
def with_cache(file_name, driver_build = nil, browser_build = nil)
|
|
161
|
+
if System.valid_cache?(file_name) && exists? && (driver_build == browser_build)
|
|
162
|
+
cached_version = System.cached_version(file_name)
|
|
163
|
+
Webdrivers.logger.debug "using cached version as latest: #{cached_version}"
|
|
164
|
+
normalize_version cached_version
|
|
164
165
|
else
|
|
165
166
|
version = yield
|
|
166
167
|
System.cache_version(file_name, version)
|
|
@@ -24,20 +24,23 @@ module Webdrivers
|
|
|
24
24
|
private
|
|
25
25
|
|
|
26
26
|
def user_defined_location
|
|
27
|
-
if Selenium::WebDriver::
|
|
28
|
-
Webdrivers.logger.debug "Selenium::WebDriver::
|
|
29
|
-
return Selenium::WebDriver::
|
|
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['
|
|
32
|
+
return if ENV['WD_EDGE_PATH'].nil?
|
|
33
33
|
|
|
34
|
-
Webdrivers.logger.debug "
|
|
35
|
-
ENV['
|
|
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
|
|
39
39
|
envs = %w[LOCALAPPDATA PROGRAMFILES PROGRAMFILES(X86)]
|
|
40
|
-
directories = ['\\Microsoft\\Edge
|
|
40
|
+
directories = ['\\Microsoft\\Edge\\Application',
|
|
41
|
+
'\\Microsoft\\Edge Beta\\Application',
|
|
42
|
+
'\\Microsoft\\Edge Dev\\Application',
|
|
43
|
+
'\\Microsoft\\Edge SxS\\Application']
|
|
41
44
|
file = 'msedge.exe'
|
|
42
45
|
|
|
43
46
|
directories.each do |dir|
|
|
@@ -52,6 +55,7 @@ module Webdrivers
|
|
|
52
55
|
def mac_location
|
|
53
56
|
directories = ['', File.expand_path('~')]
|
|
54
57
|
files = ['/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
|
|
58
|
+
'/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta',
|
|
55
59
|
'/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge Dev',
|
|
56
60
|
'/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge Canary']
|
|
57
61
|
|
|
@@ -65,6 +69,17 @@ module Webdrivers
|
|
|
65
69
|
end
|
|
66
70
|
|
|
67
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
|
|
68
83
|
raise 'Default location not yet known'
|
|
69
84
|
end
|
|
70
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
|
-
|
|
62
|
-
|
|
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
|
|
74
|
-
|
|
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
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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 }
|