webdrivers 3.8.0 → 3.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +14 -0
- data/.gitignore +7 -7
- data/.rubocop.yml +35 -19
- data/.travis.yml +24 -16
- data/CHANGELOG.md +120 -113
- data/Gemfile +6 -4
- data/LICENSE.txt +22 -22
- data/README.md +154 -153
- data/Rakefile +9 -9
- data/appveyor.yml +23 -0
- data/lib/webdrivers.rb +28 -26
- data/lib/webdrivers/chromedriver.rb +161 -140
- data/lib/webdrivers/common.rb +221 -205
- data/lib/webdrivers/geckodriver.rb +41 -43
- data/lib/webdrivers/iedriver.rb +41 -43
- data/lib/webdrivers/logger.rb +111 -109
- data/lib/webdrivers/mswebdriver.rb +59 -57
- data/lib/webdrivers/selenium.rb +40 -38
- data/spec/spec_helper.rb +12 -5
- data/spec/webdrivers/chromedriver_spec.rb +129 -104
- data/spec/webdrivers/geckodriver_spec.rb +66 -60
- data/spec/webdrivers/i_edriver_spec.rb +41 -36
- data/spec/webdrivers/ms_webdriver_spec.rb +26 -24
- data/spec/webdrivers_proxy_support_spec.rb +53 -51
- data/webdrivers.gemspec +30 -27
- metadata +27 -4
data/lib/webdrivers/selenium.rb
CHANGED
@@ -1,38 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
::Selenium::WebDriver::
|
8
|
-
::Selenium::WebDriver::
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'selenium-webdriver'
|
4
|
+
|
5
|
+
# v3.151.59 and higher
|
6
|
+
if ::Selenium::WebDriver::Service.respond_to? :driver_path=
|
7
|
+
::Selenium::WebDriver::Chrome::Service.driver_path = proc { ::Webdrivers::Chromedriver.update }
|
8
|
+
::Selenium::WebDriver::Firefox::Service.driver_path = proc { ::Webdrivers::Geckodriver.update }
|
9
|
+
::Selenium::WebDriver::Edge::Service.driver_path = proc { ::Webdrivers::MSWebdriver.update }
|
10
|
+
::Selenium::WebDriver::IE::Service.driver_path = proc { ::Webdrivers::IEdriver.update }
|
11
|
+
else
|
12
|
+
# v3.141.0 and lower
|
13
|
+
module Selenium
|
14
|
+
module WebDriver
|
15
|
+
module Chrome
|
16
|
+
def self.driver_path
|
17
|
+
@driver_path ||= Webdrivers::Chromedriver.update
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module Firefox
|
22
|
+
def self.driver_path
|
23
|
+
@driver_path ||= Webdrivers::Geckodriver.update
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Edge
|
28
|
+
def self.driver_path
|
29
|
+
@driver_path ||= Webdrivers::MSWebdriver.update
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module IE
|
34
|
+
def self.driver_path
|
35
|
+
@driver_path ||= Webdrivers::IEdriver.update
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
|
6
|
+
require 'rspec'
|
7
|
+
require 'webdrivers'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.filter_run_including focus: true unless ENV['CI']
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
end
|
@@ -1,104 +1,129 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
chromedriver.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
chromedriver.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Webdrivers::Chromedriver do
|
6
|
+
let(:chromedriver) { described_class }
|
7
|
+
|
8
|
+
it 'updates' do
|
9
|
+
chromedriver.update
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'parses chromedriver versions before 2.10' do
|
13
|
+
expect(chromedriver.send(:normalize_version, '2.9').version).to eq '2.9'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'finds latest version' do
|
17
|
+
old_version = Gem::Version.new('2.30')
|
18
|
+
future_version = Gem::Version.new('80.00')
|
19
|
+
latest_version = chromedriver.latest_version
|
20
|
+
|
21
|
+
expect(latest_version).to be > old_version
|
22
|
+
expect(latest_version).to be < future_version
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'downloads latest release for current version of Chrome by default' do
|
26
|
+
chromedriver.remove
|
27
|
+
chromedriver.download
|
28
|
+
cur_ver = chromedriver.current_version.version
|
29
|
+
latest_ver = chromedriver.latest_version.version
|
30
|
+
expect(cur_ver).to eq latest_ver
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'downloads specified version by Float' do
|
34
|
+
chromedriver.remove
|
35
|
+
chromedriver.version = 2.29
|
36
|
+
chromedriver.download
|
37
|
+
expect(chromedriver.current_version.version).to include '2.29'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'downloads specified version by String' do
|
41
|
+
chromedriver.remove
|
42
|
+
chromedriver.version = '73.0.3683.68'
|
43
|
+
chromedriver.download
|
44
|
+
expect(chromedriver.current_version.version).to eq '73.0.3683.68'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'removes chromedriver' do
|
48
|
+
chromedriver.remove
|
49
|
+
expect(chromedriver.current_version).to be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when using a Chromium version < 70.0.3538' do
|
53
|
+
it 'downloads chromedriver 2.46' do
|
54
|
+
chromedriver.remove
|
55
|
+
chromedriver.version = nil
|
56
|
+
chromedriver.instance_variable_set('@latest_version', nil)
|
57
|
+
|
58
|
+
allow(chromedriver).to receive(:chrome_version).and_return('70.0.0')
|
59
|
+
chromedriver.update
|
60
|
+
|
61
|
+
expect(chromedriver.current_version.version[/\d+.\d+/]).to eq('2.46')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when using a Chromium version that does not have an associated driver' do
|
66
|
+
before do
|
67
|
+
chromedriver.remove
|
68
|
+
chromedriver.version = nil
|
69
|
+
chromedriver.instance_variable_set('@latest_version', nil)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'raises an exception for beta version' do
|
73
|
+
allow(chromedriver).to receive(:chrome_version).and_return('100.0.0')
|
74
|
+
msg = 'you appear to be using a non-production version of Chrome; please set '\
|
75
|
+
'`Webdrivers::Chromedriver.version = <desired driver version>` to an known chromedriver version: '\
|
76
|
+
'https://chromedriver.storage.googleapis.com/index.html'
|
77
|
+
expect { chromedriver.update }.to raise_exception(StandardError, msg)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'raises an exception for unknown version' do
|
81
|
+
allow(chromedriver).to receive(:chrome_version).and_return('72.0.0')
|
82
|
+
msg = 'please set `Webdrivers::Chromedriver.version = <desired driver version>` to an known chromedriver '\
|
83
|
+
'version: https://chromedriver.storage.googleapis.com/index.html'
|
84
|
+
expect { chromedriver.update }.to raise_exception(StandardError, msg)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Workaround for Google Chrome when using Jruby on Windows.
|
89
|
+
# @see https://github.com/titusfortner/webdrivers/issues/41
|
90
|
+
if RUBY_PLATFORM == 'java' && Selenium::WebDriver::Platform.windows?
|
91
|
+
context 'when using Jruby on Windows' do
|
92
|
+
it 'uses Jruby specific workaround to retrieve the Google Chrome version' do
|
93
|
+
chromedriver.remove
|
94
|
+
chromedriver.update
|
95
|
+
expect(chromedriver.current_version).not_to be_nil
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when offline' do
|
101
|
+
before do
|
102
|
+
chromedriver.instance_variable_set('@latest_version', nil)
|
103
|
+
allow(chromedriver).to receive(:site_available?).and_return(false)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'raises exception finding latest version' do
|
107
|
+
expect { chromedriver.latest_version }.to raise_error(StandardError, 'Can not reach site')
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'raises exception downloading' do
|
111
|
+
expect { chromedriver.download }.to raise_error(StandardError, 'Can not reach site')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'allows setting of install directory' do
|
116
|
+
begin
|
117
|
+
install_dir = File.expand_path(File.join(ENV['HOME'], '.webdrivers2'))
|
118
|
+
Webdrivers.install_dir = install_dir
|
119
|
+
expect(chromedriver.install_dir).to eq install_dir
|
120
|
+
ensure
|
121
|
+
Webdrivers.install_dir = nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'returns full location of binary' do
|
126
|
+
install_dir = File.expand_path(File.join(ENV['HOME'], '.webdrivers'))
|
127
|
+
expect(chromedriver.binary).to match %r{#{install_dir}/chromedriver}
|
128
|
+
end
|
129
|
+
end
|
@@ -1,60 +1,66 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
geckodriver.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Webdrivers::Geckodriver do
|
6
|
+
let(:geckodriver) { described_class }
|
7
|
+
|
8
|
+
it 'raises exception if unable to get latest geckodriver and no geckodriver present' do
|
9
|
+
geckodriver.remove
|
10
|
+
allow(geckodriver).to receive(:desired_version).and_return(nil)
|
11
|
+
gd = 'Unable to find the latest version of geckodriver'
|
12
|
+
msg = /^#{gd}(.exe)?; try downloading manually from (.*)?and place in (.*)?\.webdrivers$/
|
13
|
+
expect { geckodriver.update }.to raise_exception StandardError, msg
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'uses found version of geckodriver if latest release unable to be found' do
|
17
|
+
geckodriver.download
|
18
|
+
allow(geckodriver).to receive(:desired_version).and_return(nil)
|
19
|
+
expect(geckodriver.update).to match(%r{\.webdrivers/geckodriver})
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'finds latest version' do
|
23
|
+
old_version = Gem::Version.new('0.17')
|
24
|
+
future_version = Gem::Version.new('0.30')
|
25
|
+
desired_version = geckodriver.desired_version
|
26
|
+
|
27
|
+
expect(desired_version).to be > old_version
|
28
|
+
expect(desired_version).to be < future_version
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'downloads latest version by default' do
|
32
|
+
geckodriver.download
|
33
|
+
expect(geckodriver.current_version).to eq geckodriver.desired_version
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'downloads specified version' do
|
37
|
+
begin
|
38
|
+
geckodriver.remove
|
39
|
+
geckodriver.version = '0.17.0'
|
40
|
+
geckodriver.download
|
41
|
+
expect(geckodriver.current_version.version).to eq '0.17.0'
|
42
|
+
ensure
|
43
|
+
geckodriver.version = nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'removes geckodriver' do
|
48
|
+
geckodriver.remove
|
49
|
+
expect(geckodriver.current_version).to be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when offline' do
|
53
|
+
before do
|
54
|
+
geckodriver.instance_variable_set('@latest_version', nil)
|
55
|
+
allow(geckodriver).to receive(:site_available?).and_return(false)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'raises exception finding latest version' do
|
59
|
+
expect { geckodriver.desired_version }.to raise_error(StandardError, 'Can not reach site')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'raises exception downloading' do
|
63
|
+
expect { geckodriver.download }.to raise_error(StandardError, 'Can not reach site')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|