webdrivers 4.3.0 → 4.4.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/.travis.yml +8 -8
- data/CHANGELOG.md +8 -0
- data/README.md +4 -4
- data/appveyor.yml +10 -10
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/webdrivers/chrome_finder.rb +31 -1
- data/lib/webdrivers/chromedriver.rb +30 -10
- data/lib/webdrivers/common.rb +9 -3
- data/lib/webdrivers/system.rb +19 -0
- 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/edgedriver_spec.rb +16 -12
- data/spec/webdrivers/geckodriver_spec.rb +2 -1
- data/spec/webdrivers/i_edriver_spec.rb +2 -1
- data/spec/webdrivers/system_spec.rb +73 -0
- data/webdrivers.gemspec +0 -2
- metadata +12 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f905a3a4839d0f0a56317926d560cab4ee29f98b3d36d4feb1bb671e3f1b23b
|
4
|
+
data.tar.gz: 44ae96f9ba7edfbb2fb1bd1fd7ef319e73643f5a43c0fce59c51e2b94c1a25c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d60000abc1ad06f692ee556bca7bd57403cde91f2152b5349fda2b0feaa2afb261dd87b1e16f6f8c74e843634b8dbde3da85ed666164920e78163fed764029
|
7
|
+
data.tar.gz: 1c94fde9cafdb1929a3e70ada28c7dfec07cbae6f68220e247ffe62343700c5b3ca2c0556d1d028d4d25b0f6bbd76923c402f1925574ec6f117eb8c4066e6255
|
data/.travis.yml
CHANGED
@@ -8,25 +8,25 @@ addons:
|
|
8
8
|
chrome: stable
|
9
9
|
script: bundle exec rake $RAKE_TASK
|
10
10
|
before_install:
|
11
|
-
- gem update --system
|
12
|
-
- gem
|
11
|
+
- gem update --system -N
|
12
|
+
- gem install bundler -N
|
13
13
|
matrix:
|
14
14
|
include:
|
15
|
-
- rvm: 2.
|
15
|
+
- rvm: 2.4
|
16
16
|
env: RAKE_TASK=spec
|
17
|
-
- rvm: 2.5
|
17
|
+
- rvm: 2.5
|
18
18
|
env: RAKE_TASK=spec
|
19
|
-
- rvm: 2.
|
19
|
+
- rvm: 2.6
|
20
20
|
env: RAKE_TASK=spec
|
21
|
-
- rvm: 2.7
|
21
|
+
- rvm: 2.7
|
22
22
|
os: osx
|
23
23
|
env: RAKE_TASK=spec
|
24
|
-
- rvm: 2.
|
24
|
+
- rvm: 2.7
|
25
25
|
env: RAKE_TASK=rubocop
|
26
26
|
- rvm: jruby-9.2.11.1
|
27
27
|
jdk: openjdk8
|
28
28
|
env: RAKE_TASK=spec
|
29
|
-
- rvm: 2.7
|
29
|
+
- rvm: 2.7
|
30
30
|
env: RAKE_TASK=spec
|
31
31
|
gemfile: gemfiles/Gemfile.edge
|
32
32
|
os: osx
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 4.4.0 (2020-05-31)
|
2
|
+
* Implement initial support for WSLv1 ([#172](https://github.com/titusfortner/webdrivers/issues/172)). Thanks G-Rath!
|
3
|
+
* Chrome/Edgedriver - Fix [#171](https://github.com/titusfortner/webdrivers/issues/171) by making sure the cached
|
4
|
+
driver build version matches the browser build version before using it.
|
5
|
+
* Chrome/Edgedriver - Driver version check now matches the driver and browser `major.minor.build` versions instead of just
|
6
|
+
the major version to be fully compliant with the `chromedriver` version selection
|
7
|
+
[document](https://chromedriver.chromium.org/downloads/version-selection).
|
8
|
+
|
1
9
|
### 4.3.0 (2020-04-14)
|
2
10
|
* Add support for Microsoft Edge (Chromium) stable
|
3
11
|
* Drop support for Ruby < 2.4.0
|
data/README.md
CHANGED
@@ -92,10 +92,10 @@ variable. **Only set one to avoid confusion**.
|
|
92
92
|
|
93
93
|
##### Special exception for chromedriver and msedgedriver
|
94
94
|
|
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.
|
95
|
+
Cache time will be respected as long as a driver binary exists and the major.minor.build versions of
|
96
|
+
the browser and the driver match. For example, if you update Chrome or Edge to v76.0.123 and its driver is
|
97
|
+
still at v76.0.100, `webdrivers` will ignore the cache time and update the driver to make sure you're
|
98
|
+
using a compatible build version.
|
99
99
|
|
100
100
|
### Proxy
|
101
101
|
|
data/appveyor.yml
CHANGED
@@ -2,22 +2,22 @@ build: off
|
|
2
2
|
cache:
|
3
3
|
- vendor/bundle
|
4
4
|
image:
|
5
|
-
- Visual Studio
|
5
|
+
- Visual Studio 2019
|
6
6
|
environment:
|
7
7
|
matrix:
|
8
|
-
- RUBY_VERSION: Ruby24
|
8
|
+
- RUBY_VERSION: Ruby24-x64
|
9
9
|
RUBY_BIN: ruby
|
10
|
-
RAKE_TASK:
|
10
|
+
RAKE_TASK: rubocop
|
11
11
|
SCRIPT_CONTEXT: bundle exec
|
12
|
-
- RUBY_VERSION: Ruby24
|
12
|
+
- RUBY_VERSION: Ruby24-x64
|
13
13
|
RUBY_BIN: ruby
|
14
|
-
RAKE_TASK:
|
14
|
+
RAKE_TASK: spec
|
15
15
|
SCRIPT_CONTEXT: bundle exec
|
16
|
-
- RUBY_VERSION: Ruby25
|
16
|
+
- RUBY_VERSION: Ruby25-x64
|
17
17
|
RUBY_BIN: ruby
|
18
18
|
RAKE_TASK: spec
|
19
19
|
SCRIPT_CONTEXT: bundle exec
|
20
|
-
- RUBY_VERSION: Ruby26
|
20
|
+
- RUBY_VERSION: Ruby26-x64
|
21
21
|
RUBY_BIN: ruby
|
22
22
|
RAKE_TASK: spec
|
23
23
|
SCRIPT_CONTEXT: bundle exec
|
@@ -25,7 +25,7 @@ environment:
|
|
25
25
|
RUBY_BIN: jruby
|
26
26
|
RAKE_TASK: spec
|
27
27
|
SCRIPT_CONTEXT: jruby -G -S
|
28
|
-
- RUBY_VERSION: Ruby26
|
28
|
+
- RUBY_VERSION: Ruby26-x64
|
29
29
|
RUBY_BIN: ruby
|
30
30
|
RAKE_TASK: spec
|
31
31
|
SCRIPT_CONTEXT: bundle exec
|
@@ -34,8 +34,8 @@ install:
|
|
34
34
|
- ps: if ($env:RUBY_BIN -eq 'jruby') { support\install_jruby.ps1 }
|
35
35
|
- ps: support\install_msedge.ps1
|
36
36
|
- set PATH=C:\%RUBY_VERSION%\bin;%PATH%
|
37
|
-
- '%RUBY_BIN% -S gem update --system'
|
38
|
-
- '%RUBY_BIN% -S gem install bundler'
|
37
|
+
- '%RUBY_BIN% -S gem update --system -N'
|
38
|
+
- '%RUBY_BIN% -S gem install bundler -N'
|
39
39
|
- '%RUBY_BIN% -S bundle install'
|
40
40
|
before_test:
|
41
41
|
- '%RUBY_BIN% -v'
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'webdrivers'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -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?
|
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,16 @@ 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("powershell.exe \"(Get-ItemProperty '#{location}').VersionInfo.ProductVersion\"")&.strip
|
108
|
+
end
|
109
|
+
|
110
|
+
def wsl_version(location)
|
111
|
+
win_version(System.to_win32_path(location))
|
84
112
|
end
|
85
113
|
|
86
114
|
def linux_version(location)
|
115
|
+
return wsl_version(location) if System.wsl?
|
116
|
+
|
87
117
|
System.call(location, '--product-version')&.strip
|
88
118
|
end
|
89
119
|
|
@@ -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)
|
@@ -80,7 +85,7 @@ module Webdrivers
|
|
80
85
|
end
|
81
86
|
|
82
87
|
def file_name
|
83
|
-
System.platform == 'win' ? 'chromedriver.exe' : 'chromedriver'
|
88
|
+
System.platform == 'win' || System.wsl? ? 'chromedriver.exe' : 'chromedriver'
|
84
89
|
end
|
85
90
|
|
86
91
|
def download_url
|
@@ -92,24 +97,39 @@ module Webdrivers
|
|
92
97
|
normalize_version(required_version)
|
93
98
|
end
|
94
99
|
|
95
|
-
file_name = System.platform == 'win' ? 'win32' : "#{System.platform}64"
|
100
|
+
file_name = System.platform == 'win' || System.wsl? ? 'win32' : "#{System.platform}64"
|
96
101
|
url = "#{base_url}/#{version}/chromedriver_#{file_name}.zip"
|
97
102
|
Webdrivers.logger.debug "chromedriver URL: #{url}"
|
98
103
|
@download_url = url
|
99
104
|
end
|
100
105
|
|
101
|
-
# Returns
|
106
|
+
# Returns major.minor.build version from the currently installed chromedriver version
|
102
107
|
#
|
103
108
|
# @example
|
104
|
-
# 73.0.3683.
|
105
|
-
def
|
106
|
-
|
107
|
-
|
109
|
+
# 73.0.3683.68 (major.minor.build.patch) -> 73.0.3683 (major.minor.build)
|
110
|
+
def current_build_version
|
111
|
+
build_ver = if current_version.nil? # Driver not found
|
112
|
+
nil
|
113
|
+
else
|
114
|
+
current_version.segments[0..2].join('.')
|
115
|
+
end
|
116
|
+
normalize_version(build_ver)
|
108
117
|
end
|
109
118
|
|
119
|
+
# Returns major.minor.build version from the currently installed Chrome version
|
120
|
+
#
|
121
|
+
# @example
|
122
|
+
# 73.0.3683.75 (major.minor.build.patch) -> 73.0.3683 (major.minor.build)
|
123
|
+
def browser_build_version
|
124
|
+
normalize_version(browser_version.segments[0..2].join('.'))
|
125
|
+
end
|
126
|
+
alias chrome_build_version browser_build_version
|
127
|
+
|
128
|
+
# Returns true if an executable driver binary exists
|
129
|
+
# and its build version matches the browser build version
|
110
130
|
def sufficient_binary?
|
111
131
|
super && current_version && (current_version < normalize_version('70.0.3538') ||
|
112
|
-
|
132
|
+
current_build_version == browser_build_version)
|
113
133
|
end
|
114
134
|
end
|
115
135
|
end
|
data/lib/webdrivers/common.rb
CHANGED
@@ -157,9 +157,15 @@ module Webdrivers
|
|
157
157
|
nil
|
158
158
|
end
|
159
159
|
|
160
|
-
|
161
|
-
|
162
|
-
|
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)
|
data/lib/webdrivers/system.rb
CHANGED
@@ -148,6 +148,25 @@ module Webdrivers
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
+
# @return [TrueClass, FalseClass]
|
152
|
+
def wsl?
|
153
|
+
platform == 'linux' && File.open('/proc/version').read.include?('Microsoft')
|
154
|
+
end
|
155
|
+
|
156
|
+
# @param [String] path
|
157
|
+
# @return [String]
|
158
|
+
def to_win32_path(path)
|
159
|
+
return path if /[a-z]:\\/iu.match?(path)
|
160
|
+
|
161
|
+
call("wslpath -w '#{path}'").chomp
|
162
|
+
end
|
163
|
+
|
164
|
+
# @param [String] path
|
165
|
+
# @return [String]
|
166
|
+
def to_wsl_path(path)
|
167
|
+
call("wslpath -u '#{path}'").chomp
|
168
|
+
end
|
169
|
+
|
151
170
|
def bitsize
|
152
171
|
Selenium::WebDriver::Platform.bitsize
|
153
172
|
end
|
data/lib/webdrivers/version.rb
CHANGED
@@ -47,4 +47,57 @@ describe Webdrivers::ChromeFinder do
|
|
47
47
|
expect { chrome_finder.version }.to raise_error(Webdrivers::BrowserNotFound)
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
context 'when running in WSL' do
|
52
|
+
before do
|
53
|
+
skip "The current platform cannot be WSL, as it's not Linux" unless Selenium::WebDriver::Platform.linux?
|
54
|
+
|
55
|
+
allow(Webdrivers::System).to receive(:wsl?).and_return(true)
|
56
|
+
allow(Webdrivers::System).to receive(:to_wsl_path).and_return('')
|
57
|
+
allow(Webdrivers::System).to receive(:to_win32_path).and_return('')
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'checks Windows locations for Chrome' do
|
61
|
+
drive = 'c'
|
62
|
+
user = 'WinUser'
|
63
|
+
file = 'chrome.exe'
|
64
|
+
path = [
|
65
|
+
'/home/wsl-user/.local/bin',
|
66
|
+
'/usr/local/bin',
|
67
|
+
'/usr/local/games',
|
68
|
+
'/usr/bin',
|
69
|
+
"/#{drive}/Users/#{user}/AppData/Local/Microsoft/WindowsApps",
|
70
|
+
'/snap/bin'
|
71
|
+
].join ':'
|
72
|
+
|
73
|
+
allow(chrome_finder).to receive(:user_defined_location).and_return(nil)
|
74
|
+
allow(ENV).to receive(:[]).with('WD_CHROME_PATH').and_return(nil)
|
75
|
+
allow(ENV).to receive(:[]).with('PATH').and_return(path)
|
76
|
+
allow(File).to receive(:exist?).and_return(false)
|
77
|
+
|
78
|
+
locations = [
|
79
|
+
"#{drive}:\\Users\\#{user}\\AppData\\Local\\Google\\Chrome\\Application\\#{file}",
|
80
|
+
"#{drive}:\\Program Files (x86)\\Chromium\\Application\\#{file}",
|
81
|
+
"#{drive}:\\Program Files\\Google\\Chrome\\Application\\#{file}"
|
82
|
+
]
|
83
|
+
|
84
|
+
# CIs don't support WSL yet, so our mocks lead to the error path for simplicity
|
85
|
+
expect { chrome_finder.location }.to raise_error(Webdrivers::BrowserNotFound)
|
86
|
+
|
87
|
+
locations.each do |dir|
|
88
|
+
expect(Webdrivers::System).to have_received(:to_wsl_path).with(dir)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'uses win_version to get the Chrome version using win32 path' do
|
93
|
+
allow(chrome_finder).to receive(:win_version).and_return('')
|
94
|
+
allow(File).to receive(:exist?).and_return(true)
|
95
|
+
|
96
|
+
# CIs don't support WSL yet, so our mocks lead to the error path for simplicity
|
97
|
+
expect { chrome_finder.version }.to raise_error(Webdrivers::VersionError)
|
98
|
+
|
99
|
+
expect(Webdrivers::System).to have_received(:to_win32_path)
|
100
|
+
expect(chrome_finder).to have_received(:win_version)
|
101
|
+
end
|
102
|
+
end
|
50
103
|
end
|
@@ -106,15 +106,16 @@ describe Webdrivers::Chromedriver do
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
it 'makes
|
109
|
+
it 'makes network calls if cached driver does not match the browser' do
|
110
110
|
Webdrivers::System.cache_version('chromedriver', '71.0.3578.137')
|
111
|
+
allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('71.0.3578.137'))
|
111
112
|
allow(chromedriver).to receive(:browser_version).and_return(Gem::Version.new('73.0.3683.68'))
|
112
113
|
allow(Webdrivers::Network).to receive(:get).and_return('73.0.3683.68')
|
113
114
|
allow(Webdrivers::System).to receive(:download)
|
114
115
|
|
115
116
|
chromedriver.update
|
116
117
|
|
117
|
-
expect(Webdrivers::Network).to have_received(:get).
|
118
|
+
expect(Webdrivers::Network).to have_received(:get).twice
|
118
119
|
end
|
119
120
|
|
120
121
|
context 'when required version is 0' do
|
@@ -155,19 +156,19 @@ describe Webdrivers::Chromedriver do
|
|
155
156
|
|
156
157
|
describe '#latest_version' do
|
157
158
|
it 'returns 2.41 if the browser version is less than 70' do
|
158
|
-
allow(chromedriver).to receive(:browser_version).and_return('69.0.0')
|
159
|
+
allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('69.0.0')
|
159
160
|
|
160
161
|
expect(chromedriver.latest_version).to eq(Gem::Version.new('2.41'))
|
161
162
|
end
|
162
163
|
|
163
164
|
it 'returns the correct point release for a production version greater than 70' do
|
164
|
-
allow(chromedriver).to receive(:browser_version).and_return '71.0.3578.9999'
|
165
|
+
allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('71.0.3578.9999')
|
165
166
|
|
166
167
|
expect(chromedriver.latest_version).to eq Gem::Version.new('71.0.3578.137')
|
167
168
|
end
|
168
169
|
|
169
170
|
it 'raises VersionError for beta version' do
|
170
|
-
allow(chromedriver).to receive(:browser_version).and_return('100.0.0')
|
171
|
+
allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('100.0.0')
|
171
172
|
msg = 'Unable to find latest point release version for 100.0.0. '\
|
172
173
|
'You appear to be using a non-production version of Chrome. '\
|
173
174
|
'Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` '\
|
@@ -177,7 +178,7 @@ describe Webdrivers::Chromedriver do
|
|
177
178
|
end
|
178
179
|
|
179
180
|
it 'raises VersionError for unknown version' do
|
180
|
-
allow(chromedriver).to receive(:browser_version).and_return('72.0.9999.0000')
|
181
|
+
allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('72.0.9999.0000')
|
181
182
|
msg = 'Unable to find latest point release version for 72.0.9999. '\
|
182
183
|
'Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` '\
|
183
184
|
'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
|
@@ -199,9 +200,12 @@ describe Webdrivers::Chromedriver do
|
|
199
200
|
expect(File.exist?("#{Webdrivers::System.install_dir}/chromedriver.version")).to eq true
|
200
201
|
end
|
201
202
|
|
202
|
-
it 'does not make network
|
203
|
+
it 'does not make network calls if cache is valid and driver exists' do
|
203
204
|
allow(Webdrivers).to receive(:cache_time).and_return(3600)
|
204
205
|
Webdrivers::System.cache_version('chromedriver', '71.0.3578.137')
|
206
|
+
allow(chromedriver).to receive(:current_version).and_return Gem::Version.new('71.0.3578.137')
|
207
|
+
allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('71.0.3578.137')
|
208
|
+
allow(Webdrivers::System).to receive(:exists?).and_return(true)
|
205
209
|
allow(Webdrivers::Network).to receive(:get)
|
206
210
|
|
207
211
|
expect(chromedriver.latest_version).to eq Gem::Version.new('71.0.3578.137')
|
@@ -209,10 +213,11 @@ describe Webdrivers::Chromedriver do
|
|
209
213
|
expect(Webdrivers::Network).not_to have_received(:get)
|
210
214
|
end
|
211
215
|
|
212
|
-
it 'makes
|
216
|
+
it 'makes network calls if cache is expired' do
|
213
217
|
Webdrivers::System.cache_version('chromedriver', '71.0.3578.137')
|
218
|
+
allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('71.0.3578.137')
|
214
219
|
allow(Webdrivers::Network).to receive(:get).and_return('73.0.3683.68')
|
215
|
-
allow(Webdrivers::System).to receive(:valid_cache?)
|
220
|
+
allow(Webdrivers::System).to receive(:valid_cache?).and_return(false)
|
216
221
|
|
217
222
|
expect(chromedriver.latest_version).to eq Gem::Version.new('73.0.3683.68')
|
218
223
|
|
@@ -114,15 +114,16 @@ describe Webdrivers::Edgedriver do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
it 'makes
|
117
|
+
it 'makes network calls if cached driver does not match the browser' do
|
118
118
|
Webdrivers::System.cache_version('msedgedriver', '71.0.3578.137')
|
119
|
-
allow(edgedriver).to receive(:
|
119
|
+
allow(edgedriver).to receive(:current_version).and_return Gem::Version.new('71.0.3578.137')
|
120
|
+
allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('73.0.3683.68')
|
120
121
|
allow(Webdrivers::Network).to receive(:get).and_return('73.0.3683.68'.encode('UTF-16'))
|
121
122
|
allow(Webdrivers::System).to receive(:download)
|
122
123
|
|
123
124
|
edgedriver.update
|
124
125
|
|
125
|
-
expect(Webdrivers::Network).to have_received(:get).
|
126
|
+
expect(Webdrivers::Network).to have_received(:get).twice
|
126
127
|
end
|
127
128
|
|
128
129
|
context 'when required version is 0' do
|
@@ -163,13 +164,13 @@ describe Webdrivers::Edgedriver do
|
|
163
164
|
|
164
165
|
describe '#latest_version' do
|
165
166
|
it 'returns the correct point release for a production version' do
|
166
|
-
allow(edgedriver).to receive(:browser_version).and_return '77.0.207.0'
|
167
|
+
allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('77.0.207.0')
|
167
168
|
|
168
169
|
expect(edgedriver.latest_version).to be_between(Gem::Version.new('77.0.207.0'), Gem::Version.new('78'))
|
169
170
|
end
|
170
171
|
|
171
172
|
it 'raises VersionError for beta version' do
|
172
|
-
allow(edgedriver).to receive(:browser_version).and_return('100.0.0')
|
173
|
+
allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('100.0.0')
|
173
174
|
msg = 'Unable to find latest point release version for 100.0.0. '\
|
174
175
|
'You appear to be using a non-production version of Edge. '\
|
175
176
|
'Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` '\
|
@@ -196,28 +197,31 @@ describe Webdrivers::Edgedriver do
|
|
196
197
|
end
|
197
198
|
|
198
199
|
it 'creates cached file' do
|
199
|
-
allow(edgedriver).to receive(:browser_version).and_return('77.0.207.0')
|
200
|
+
allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('77.0.207.0')
|
200
201
|
allow(Webdrivers::Network).to receive(:get).and_return('77.0.207.0'.encode('UTF-16'))
|
201
202
|
|
202
203
|
edgedriver.latest_version
|
203
204
|
expect(File.exist?("#{Webdrivers::System.install_dir}/msedgedriver.version")).to eq true
|
204
205
|
end
|
205
206
|
|
206
|
-
it 'does not make network
|
207
|
+
it 'does not make network calls if cache is valid and driver exists' do
|
207
208
|
allow(Webdrivers).to receive(:cache_time).and_return(3600)
|
208
|
-
Webdrivers::System.cache_version('msedgedriver', '
|
209
|
+
Webdrivers::System.cache_version('msedgedriver', '82.0.445.0')
|
210
|
+
allow(edgedriver).to receive(:current_version).and_return Gem::Version.new('82.0.445.0')
|
211
|
+
allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('82.0.445.0')
|
212
|
+
allow(Webdrivers::System).to receive(:exists?).and_return(true)
|
209
213
|
allow(Webdrivers::Network).to receive(:get)
|
210
214
|
|
211
|
-
expect(edgedriver.latest_version).to eq Gem::Version.new('
|
215
|
+
expect(edgedriver.latest_version).to eq Gem::Version.new('82.0.445.0')
|
212
216
|
|
213
217
|
expect(Webdrivers::Network).not_to have_received(:get)
|
214
218
|
end
|
215
219
|
|
216
|
-
it 'makes
|
220
|
+
it 'makes network calls if cache is expired' do
|
217
221
|
Webdrivers::System.cache_version('msedgedriver', '71.0.3578.137')
|
218
222
|
allow(Webdrivers::Network).to receive(:get).and_return('77.0.207.0'.encode('UTF-16'))
|
219
|
-
allow(Webdrivers::System).to receive(:valid_cache?)
|
220
|
-
allow(edgedriver).to receive(:browser_version).and_return('77.0.207.0')
|
223
|
+
allow(Webdrivers::System).to receive(:valid_cache?).and_return(false)
|
224
|
+
allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('77.0.207.0')
|
221
225
|
|
222
226
|
expect(edgedriver.latest_version).to eq Gem::Version.new('77.0.207.0')
|
223
227
|
|
@@ -135,9 +135,10 @@ You can obtain a copy of the license at https://mozilla.org/MPL/2.0/"
|
|
135
135
|
expect(File.exist?("#{Webdrivers::System.install_dir}/geckodriver.version")).to eq true
|
136
136
|
end
|
137
137
|
|
138
|
-
it 'does not make network
|
138
|
+
it 'does not make network calls if cache is valid and driver exists' do
|
139
139
|
allow(Webdrivers).to receive(:cache_time).and_return(3600)
|
140
140
|
Webdrivers::System.cache_version('geckodriver', '0.23.0')
|
141
|
+
allow(Webdrivers::System).to receive(:exists?).and_return(true)
|
141
142
|
allow(Webdrivers::Network).to receive(:get)
|
142
143
|
|
143
144
|
expect(geckodriver.latest_version).to eq Gem::Version.new('0.23.0')
|
@@ -115,9 +115,10 @@ describe Webdrivers::IEdriver do
|
|
115
115
|
expect(File.exist?("#{Webdrivers::System.install_dir}/IEDriverServer.version")).to eq true
|
116
116
|
end
|
117
117
|
|
118
|
-
it 'does not make network
|
118
|
+
it 'does not make network calls if cache is valid and driver exists' do
|
119
119
|
allow(Webdrivers).to receive(:cache_time).and_return(3600)
|
120
120
|
Webdrivers::System.cache_version('IEDriverServer', '3.4.0')
|
121
|
+
allow(Webdrivers::System).to receive(:exists?).and_return(true)
|
121
122
|
allow(Webdrivers::Network).to receive(:get)
|
122
123
|
|
123
124
|
expect(iedriver.latest_version).to eq Gem::Version.new('3.4.0')
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
wsl_proc_contents = [
|
6
|
+
'Linux version 4.4.0-18362-Microsoft',
|
7
|
+
'(Microsoft@Microsoft.com)',
|
8
|
+
'(gcc version 5.4.0 (GCC) )',
|
9
|
+
'#836-Microsoft',
|
10
|
+
'Mon May 05 16:04:00 PST 2020'
|
11
|
+
].join ' '
|
12
|
+
|
13
|
+
describe Webdrivers::System do
|
14
|
+
describe '#wsl?' do
|
15
|
+
context 'when the current platform is linux' do
|
16
|
+
before { allow(described_class).to receive(:platform).and_return 'linux' }
|
17
|
+
|
18
|
+
it 'checks /proc/version' do
|
19
|
+
allow(File).to receive(:open).with('/proc/version').and_return(StringIO.new(wsl_proc_contents))
|
20
|
+
|
21
|
+
expect(described_class.wsl?).to eq true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the current platform is mac' do
|
26
|
+
before { allow(described_class).to receive(:platform).and_return 'mac' }
|
27
|
+
|
28
|
+
it 'does not bother checking proc' do
|
29
|
+
allow(File).to receive(:open).and_call_original
|
30
|
+
|
31
|
+
expect(described_class.wsl?).to eq false
|
32
|
+
|
33
|
+
expect(File).not_to have_received(:open).with('/proc/version')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#to_win32_path' do
|
39
|
+
before { allow(described_class).to receive(:call).and_return("C:\\path\\to\\folder\n") }
|
40
|
+
|
41
|
+
it 'uses wslpath' do
|
42
|
+
described_class.to_win32_path '/c/path/to/folder'
|
43
|
+
|
44
|
+
expect(described_class).to have_received(:call).with('wslpath -w \'/c/path/to/folder\'')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'removes the trailing newline' do
|
48
|
+
expect(described_class.to_win32_path('/c/path/to/folder')).not_to end_with('\n')
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when the path is already in Windows format' do
|
52
|
+
it 'returns early' do
|
53
|
+
expect(described_class.to_win32_path('D:\\')).to eq 'D:\\'
|
54
|
+
|
55
|
+
expect(described_class).not_to have_received(:call)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#to_wsl_path' do
|
61
|
+
before { allow(described_class).to receive(:call).and_return("/c/path/to/folder\n") }
|
62
|
+
|
63
|
+
it 'uses wslpath' do
|
64
|
+
described_class.to_wsl_path 'C:\\path\\to\\folder'
|
65
|
+
|
66
|
+
expect(described_class).to have_received(:call).with('wslpath -u \'C:\\path\\to\\folder\'')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'removes the trailing newline' do
|
70
|
+
expect(described_class.to_wsl_path('/c/path/to/folder')).not_to end_with('\n')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/webdrivers.gemspec
CHANGED
@@ -28,9 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.require_paths = ['lib']
|
29
29
|
|
30
30
|
s.add_development_dependency 'ffi', '~> 1.0' # For selenium-webdriver on Windows
|
31
|
-
s.add_development_dependency 'irb'
|
32
31
|
s.add_development_dependency 'rake', '~> 12.0'
|
33
|
-
s.add_development_dependency 'reline', '0.0.7' # Required by irb, and newer versions don't work on JRuby
|
34
32
|
s.add_development_dependency 'rspec', '~> 3.0'
|
35
33
|
s.add_development_dependency 'rubocop', '~>0.66'
|
36
34
|
s.add_development_dependency 'rubocop-performance'
|
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.
|
4
|
+
version: 4.4.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: 2020-
|
13
|
+
date: 2020-06-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ffi
|
@@ -26,20 +26,6 @@ dependencies:
|
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '1.0'
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: irb
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '0'
|
36
|
-
type: :development
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '0'
|
43
29
|
- !ruby/object:Gem::Dependency
|
44
30
|
name: rake
|
45
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,20 +40,6 @@ dependencies:
|
|
54
40
|
- - "~>"
|
55
41
|
- !ruby/object:Gem::Version
|
56
42
|
version: '12.0'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: reline
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - '='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: 0.0.7
|
64
|
-
type: :development
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - '='
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: 0.0.7
|
71
43
|
- !ruby/object:Gem::Dependency
|
72
44
|
name: rspec
|
73
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,7 +163,9 @@ description: Run Selenium tests more easily with install and updates for all sup
|
|
191
163
|
email:
|
192
164
|
- titusfortner@gmail.com
|
193
165
|
- kapoorlakshya@gmail.com
|
194
|
-
executables:
|
166
|
+
executables:
|
167
|
+
- console
|
168
|
+
- setup
|
195
169
|
extensions: []
|
196
170
|
extra_rdoc_files: []
|
197
171
|
files:
|
@@ -205,6 +179,8 @@ files:
|
|
205
179
|
- README.md
|
206
180
|
- Rakefile
|
207
181
|
- appveyor.yml
|
182
|
+
- bin/console
|
183
|
+
- bin/setup
|
208
184
|
- gemfiles/Gemfile.edge
|
209
185
|
- lib/webdrivers.rb
|
210
186
|
- lib/webdrivers/Rakefile
|
@@ -231,6 +207,7 @@ files:
|
|
231
207
|
- spec/webdrivers/edgedriver_spec.rb
|
232
208
|
- spec/webdrivers/geckodriver_spec.rb
|
233
209
|
- spec/webdrivers/i_edriver_spec.rb
|
210
|
+
- spec/webdrivers/system_spec.rb
|
234
211
|
- spec/webdrivers/webdrivers_spec.rb
|
235
212
|
- spec/webdrivers_proxy_support_spec.rb
|
236
213
|
- support/install_jruby.ps1
|
@@ -242,8 +219,8 @@ licenses:
|
|
242
219
|
metadata:
|
243
220
|
bug_tracker_uri: https://github.com/titusfortner/webdrivers/issues
|
244
221
|
changelog_uri: https://github.com/titusfortner/webdrivers/blob/master/CHANGELOG.md
|
245
|
-
documentation_uri: https://www.rubydoc.info/gems/webdrivers/4.
|
246
|
-
source_code_uri: https://github.com/titusfortner/webdrivers/tree/v4.
|
222
|
+
documentation_uri: https://www.rubydoc.info/gems/webdrivers/4.4.0
|
223
|
+
source_code_uri: https://github.com/titusfortner/webdrivers/tree/v4.4.0
|
247
224
|
post_install_message:
|
248
225
|
rdoc_options: []
|
249
226
|
require_paths:
|
@@ -259,17 +236,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
236
|
- !ruby/object:Gem::Version
|
260
237
|
version: '0'
|
261
238
|
requirements: []
|
262
|
-
rubygems_version: 3.1.
|
239
|
+
rubygems_version: 3.1.3
|
263
240
|
signing_key:
|
264
241
|
specification_version: 4
|
265
242
|
summary: Easy download and use of browser drivers.
|
266
|
-
test_files:
|
267
|
-
- spec/spec_helper.rb
|
268
|
-
- spec/webdrivers/chrome_finder_spec.rb
|
269
|
-
- spec/webdrivers/chromedriver_spec.rb
|
270
|
-
- spec/webdrivers/edge_finder_spec.rb
|
271
|
-
- spec/webdrivers/edgedriver_spec.rb
|
272
|
-
- spec/webdrivers/geckodriver_spec.rb
|
273
|
-
- spec/webdrivers/i_edriver_spec.rb
|
274
|
-
- spec/webdrivers/webdrivers_spec.rb
|
275
|
-
- spec/webdrivers_proxy_support_spec.rb
|
243
|
+
test_files: []
|