webdrivers 3.4.3 → 3.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/lib/webdrivers/chromedriver.rb +3 -3
- data/lib/webdrivers/common.rb +20 -21
- data/lib/webdrivers/geckodriver.rb +1 -1
- data/lib/webdrivers/iedriver.rb +1 -1
- data/lib/webdrivers/mswebdriver.rb +3 -5
- data/spec/chromedriver_spec.rb +14 -8
- data/spec/geckodriver_spec.rb +17 -12
- data/spec/iedriver_spec.rb +6 -6
- data/spec/mswebdriver_spec.rb +2 -2
- data/webdrivers.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f292b9f00d51fa84cf046500d96f6e974756f4822bea030b04f020a221912e45
|
4
|
+
data.tar.gz: bca6951770b45c20b275eceb2339e77cdaa6089a63b9ce232264c91690a2e2f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23bd4cbf655e4983b70f5405d2e2f1229b9f61743e1cfa81971a62f5e71920a07e557a6341842d9d5a44eda718c6cb79741c1b260561d5563bd2519b5abb3c9b
|
7
|
+
data.tar.gz: 37be287a21d845cbc09a7e98d524275167dd7af804a7e5a7577082e43bcfe3daaccaadf65b637dac7929a70c28561f937719b957bc45796301c4460f417ae3b7
|
data/CHANGELOG.md
CHANGED
@@ -4,15 +4,15 @@ module Webdrivers
|
|
4
4
|
class Chromedriver < Common
|
5
5
|
class << self
|
6
6
|
|
7
|
-
def
|
7
|
+
def current_version
|
8
8
|
Webdrivers.logger.debug "Checking current version"
|
9
9
|
return nil unless downloaded?
|
10
10
|
string = %x(#{binary} --version)
|
11
11
|
Webdrivers.logger.debug "Current version of #{binary} is #{string}"
|
12
|
-
normalize string.match(/ChromeDriver (\d
|
12
|
+
normalize string.match(/ChromeDriver (\d+\.\d+)/)[1]
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def latest_version
|
16
16
|
Gem::Version.new(get(URI.join(base_url, "LATEST_RELEASE")))
|
17
17
|
end
|
18
18
|
|
data/lib/webdrivers/common.rb
CHANGED
@@ -5,30 +5,40 @@ module Webdrivers
|
|
5
5
|
class Common
|
6
6
|
class << self
|
7
7
|
|
8
|
+
attr_accessor :version
|
9
|
+
|
8
10
|
def update
|
9
11
|
unless site_available?
|
10
|
-
return
|
12
|
+
return current_version.nil? ? nil : binary
|
11
13
|
end
|
12
|
-
released = latest()
|
13
|
-
location = binary()
|
14
14
|
|
15
|
-
return
|
15
|
+
return binary if desired_version.nil? && File.exists?(binary) # Newer not found, keep current
|
16
16
|
|
17
|
-
if
|
17
|
+
if desired_version.nil? # Can't find latest and no existing binary
|
18
18
|
msg = "Unable to find the latest version of #{file_name}; try downloading manually from #{base_url} and place in #{install_dir}"
|
19
19
|
raise StandardError, msg
|
20
20
|
end
|
21
21
|
|
22
22
|
if correct_binary?
|
23
23
|
Webdrivers.logger.debug "Expected webdriver version found"
|
24
|
-
return
|
24
|
+
return binary
|
25
25
|
end
|
26
26
|
|
27
27
|
remove # Remove outdated exe
|
28
28
|
download # Fetch latest
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def desired_version
|
32
|
+
if self.version.is_a?(Gem::Version)
|
33
|
+
version
|
34
|
+
elsif self.version.nil?
|
35
|
+
latest_version
|
36
|
+
else
|
37
|
+
Gem::Version.new(self.version.to_s)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def latest_version
|
32
42
|
downloads.keys.sort.last
|
33
43
|
end
|
34
44
|
|
@@ -37,8 +47,8 @@ module Webdrivers
|
|
37
47
|
FileUtils.rm_f binary
|
38
48
|
end
|
39
49
|
|
40
|
-
def download
|
41
|
-
url
|
50
|
+
def download
|
51
|
+
url = downloads[desired_version]
|
42
52
|
filename = File.basename url
|
43
53
|
|
44
54
|
FileUtils.mkdir_p(install_dir) unless File.exists?(install_dir)
|
@@ -107,17 +117,6 @@ module Webdrivers
|
|
107
117
|
Webdrivers.proxy_addr && Webdrivers.proxy_port
|
108
118
|
end
|
109
119
|
|
110
|
-
def download_url(version)
|
111
|
-
key = if version.is_a?(Gem::Version)
|
112
|
-
version
|
113
|
-
elsif version.nil?
|
114
|
-
latest
|
115
|
-
else
|
116
|
-
Gem::Version.new(version.to_s)
|
117
|
-
end
|
118
|
-
downloads[key]
|
119
|
-
end
|
120
|
-
|
121
120
|
def downloaded?
|
122
121
|
result = File.exist? binary
|
123
122
|
Webdrivers.logger.debug "File is already downloaded: #{result}"
|
@@ -187,7 +186,7 @@ module Webdrivers
|
|
187
186
|
|
188
187
|
# Already have latest version downloaded?
|
189
188
|
def correct_binary?
|
190
|
-
|
189
|
+
latest_version == current_version && File.exists?(binary)
|
191
190
|
end
|
192
191
|
|
193
192
|
def normalize(string)
|
data/lib/webdrivers/iedriver.rb
CHANGED
@@ -3,10 +3,10 @@ module Webdrivers
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
-
def
|
6
|
+
def windows_version
|
7
7
|
Webdrivers.logger.debug "Checking current version"
|
8
8
|
|
9
|
-
#
|
9
|
+
# current_version() from other webdrivers returns the version from the webdriver EXE.
|
10
10
|
# Unfortunately, MicrosoftWebDriver.exe does not have an option to get the version.
|
11
11
|
# To work around it we query the currently installed version of Microsoft Edge instead
|
12
12
|
# and compare it to the list of available downloads.
|
@@ -22,9 +22,7 @@ module Webdrivers
|
|
22
22
|
# Webdriver binaries for Microsoft Edge are not backwards compatible.
|
23
23
|
# For this reason, instead of downloading the latest binary we download the correct one for the
|
24
24
|
# currently installed browser version.
|
25
|
-
|
26
|
-
super
|
27
|
-
end
|
25
|
+
alias :version :windows_version
|
28
26
|
|
29
27
|
private
|
30
28
|
|
data/spec/chromedriver_spec.rb
CHANGED
@@ -4,6 +4,10 @@ describe Webdrivers::Chromedriver do
|
|
4
4
|
|
5
5
|
let(:chromedriver) { Webdrivers::Chromedriver }
|
6
6
|
|
7
|
+
it 'updates' do
|
8
|
+
chromedriver.update
|
9
|
+
end
|
10
|
+
|
7
11
|
it 'parses chromedriver versions before 2.10' do
|
8
12
|
expect(chromedriver.send(:normalize, '2.9').version).to eq '2.9'
|
9
13
|
end
|
@@ -11,7 +15,7 @@ describe Webdrivers::Chromedriver do
|
|
11
15
|
it 'finds latest version' do
|
12
16
|
old_version = Gem::Version.new("2.30")
|
13
17
|
future_version = Gem::Version.new("2.90")
|
14
|
-
latest_version = chromedriver.
|
18
|
+
latest_version = chromedriver.latest_version
|
15
19
|
|
16
20
|
expect(latest_version).to be > old_version
|
17
21
|
expect(latest_version).to be < future_version
|
@@ -20,31 +24,33 @@ describe Webdrivers::Chromedriver do
|
|
20
24
|
it 'downloads latest version by default' do
|
21
25
|
chromedriver.remove
|
22
26
|
chromedriver.download
|
23
|
-
expect(chromedriver.
|
27
|
+
expect(chromedriver.current_version).to eq chromedriver.latest_version
|
24
28
|
end
|
25
29
|
|
26
30
|
it 'downloads specified version by Float' do
|
27
31
|
chromedriver.remove
|
28
|
-
chromedriver.
|
29
|
-
|
32
|
+
chromedriver.version = 2.29
|
33
|
+
chromedriver.download
|
34
|
+
expect(chromedriver.current_version.version).to eq '2.29'
|
30
35
|
end
|
31
36
|
|
32
37
|
it 'downloads specified version by String' do
|
33
38
|
chromedriver.remove
|
34
|
-
chromedriver.
|
35
|
-
|
39
|
+
chromedriver.version = '2.29'
|
40
|
+
chromedriver.download
|
41
|
+
expect(chromedriver.current_version.version).to eq '2.29'
|
36
42
|
end
|
37
43
|
|
38
44
|
it 'removes chromedriver' do
|
39
45
|
chromedriver.remove
|
40
|
-
expect(chromedriver.
|
46
|
+
expect(chromedriver.current_version).to be_nil
|
41
47
|
end
|
42
48
|
|
43
49
|
context 'when offline' do
|
44
50
|
before { allow(chromedriver).to receive(:site_available?).and_return(false) }
|
45
51
|
|
46
52
|
xit 'raises exception finding latest version' do
|
47
|
-
expect {chromedriver.
|
53
|
+
expect {chromedriver.latest_version}.to raise_error(StandardError, "Can not download from website")
|
48
54
|
end
|
49
55
|
|
50
56
|
it 'raises exception downloading' do
|
data/spec/geckodriver_spec.rb
CHANGED
@@ -6,51 +6,56 @@ describe Webdrivers::Geckodriver do
|
|
6
6
|
|
7
7
|
it 'raises exception if unable to get latest geckodriver and no geckodriver present' do
|
8
8
|
geckodriver.remove
|
9
|
-
allow(geckodriver).to receive(:
|
9
|
+
allow(geckodriver).to receive(:desired_version).and_return(nil)
|
10
10
|
msg = /^Unable to find the latest version of geckodriver(.exe)?; try downloading manually from (.*)?and place in (.*)?\.webdrivers$/
|
11
11
|
expect { geckodriver.update }.to raise_exception StandardError, msg
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'uses found version of geckodriver if latest release unable to be found' do
|
15
15
|
geckodriver.download
|
16
|
-
allow(geckodriver).to receive(:
|
16
|
+
allow(geckodriver).to receive(:desired_version).and_return(nil)
|
17
17
|
expect(geckodriver.update).to match(/\.webdrivers\/geckodriver/)
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'finds latest version' do
|
21
21
|
old_version = Gem::Version.new('0.17')
|
22
22
|
future_version = Gem::Version.new('0.30')
|
23
|
-
|
23
|
+
desired_version = geckodriver.desired_version
|
24
24
|
|
25
|
-
expect(
|
26
|
-
expect(
|
25
|
+
expect(desired_version).to be > old_version
|
26
|
+
expect(desired_version).to be < future_version
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'downloads latest version by default' do
|
30
30
|
geckodriver.download
|
31
|
-
expect(geckodriver.
|
31
|
+
expect(geckodriver.current_version).to eq geckodriver.desired_version
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'downloads specified version' do
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
begin
|
36
|
+
geckodriver.remove
|
37
|
+
geckodriver.version = '0.17.0'
|
38
|
+
geckodriver.download
|
39
|
+
expect(geckodriver.current_version.version).to eq '0.17.0'
|
40
|
+
ensure
|
41
|
+
geckodriver.version = nil
|
42
|
+
end
|
38
43
|
end
|
39
44
|
|
40
45
|
it 'removes geckodriver' do
|
41
46
|
geckodriver.remove
|
42
|
-
expect(geckodriver.
|
47
|
+
expect(geckodriver.current_version).to be_nil
|
43
48
|
end
|
44
49
|
|
45
50
|
context 'when offline' do
|
46
51
|
before { allow(geckodriver).to receive(:site_available?).and_return(false) }
|
47
52
|
|
48
53
|
it 'raises exception finding latest version' do
|
49
|
-
expect {geckodriver.
|
54
|
+
expect { geckodriver.desired_version }.to raise_error(StandardError, "Can not reach site")
|
50
55
|
end
|
51
56
|
|
52
57
|
it 'raises exception downloading' do
|
53
|
-
expect {geckodriver.download}.to raise_error(StandardError, "Can not reach site")
|
58
|
+
expect { geckodriver.download }.to raise_error(StandardError, "Can not reach site")
|
54
59
|
end
|
55
60
|
end
|
56
61
|
|
data/spec/iedriver_spec.rb
CHANGED
@@ -6,11 +6,11 @@ describe Webdrivers::IEdriver do
|
|
6
6
|
|
7
7
|
it 'finds latest version' do
|
8
8
|
old_version = Gem::Version.new("3.12.0")
|
9
|
-
future_version = Gem::Version.new("
|
10
|
-
|
9
|
+
future_version = Gem::Version.new("4.0")
|
10
|
+
desired_version = iedriver.desired_version
|
11
11
|
|
12
|
-
expect(
|
13
|
-
expect(
|
12
|
+
expect(desired_version).to be > old_version
|
13
|
+
expect(desired_version).to be < future_version
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'downloads iedriver' do
|
@@ -20,14 +20,14 @@ describe Webdrivers::IEdriver do
|
|
20
20
|
|
21
21
|
it 'removes iedriver' do
|
22
22
|
iedriver.remove
|
23
|
-
expect(iedriver.
|
23
|
+
expect(iedriver.current_version).to be_nil
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'when offline' do
|
27
27
|
before { allow(iedriver).to receive(:site_available?).and_return(false) }
|
28
28
|
|
29
29
|
it 'raises exception finding latest version' do
|
30
|
-
expect {iedriver.
|
30
|
+
expect {iedriver.latest_version}.to raise_error(StandardError, "Can not reach site")
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'raises exception downloading' do
|
data/spec/mswebdriver_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Webdrivers::MSWebdriver do
|
|
6
6
|
|
7
7
|
it 'downloads mswebdriver' do
|
8
8
|
mswebdriver.remove
|
9
|
-
allow(mswebdriver).to receive(:
|
9
|
+
allow(mswebdriver).to receive(:desired_version).and_return(mswebdriver.latest_version)
|
10
10
|
expect(File.exist?(mswebdriver.download)).to be true
|
11
11
|
end
|
12
12
|
|
@@ -19,7 +19,7 @@ describe Webdrivers::MSWebdriver do
|
|
19
19
|
before { allow(mswebdriver).to receive(:site_available?).and_return(false) }
|
20
20
|
|
21
21
|
it 'raises exception downloading' do
|
22
|
-
expect { mswebdriver.download }.to raise_error(
|
22
|
+
expect { mswebdriver.download }.to raise_error(StandardError, "Can not reach site")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/webdrivers.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "webdrivers"
|
6
|
-
s.version = "3.
|
6
|
+
s.version = "3.5.0.beta1"
|
7
7
|
s.authors = ["Titus Fortner"]
|
8
8
|
s.email = ["titusfortner@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/titusfortner/webdrivers"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdrivers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -125,12 +125,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- - "
|
128
|
+
- - ">"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
130
|
+
version: 1.3.1
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.7.6
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Easy download and use of browser drivers.
|