webdrivers 3.9.1 → 3.9.2
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 +5 -5
- data/.github/ISSUE_TEMPLATE.md +13 -13
- data/.gitignore +7 -7
- data/.rubocop.yml +44 -44
- data/.travis.yml +24 -24
- data/CHANGELOG.md +137 -133
- data/Gemfile +6 -6
- data/LICENSE.txt +22 -22
- data/README.md +169 -169
- data/Rakefile +11 -11
- data/appveyor.yml +22 -22
- data/lib/webdrivers.rb +6 -6
- data/lib/webdrivers/chromedriver.rb +185 -167
- data/lib/webdrivers/common.rb +191 -157
- data/lib/webdrivers/geckodriver.rb +80 -72
- data/lib/webdrivers/iedriver.rb +70 -62
- data/lib/webdrivers/logger.rb +111 -111
- data/lib/webdrivers/mswebdriver.rb +55 -55
- data/lib/webdrivers/network.rb +61 -58
- data/lib/webdrivers/system.rb +154 -151
- data/spec/spec_helper.rb +18 -18
- data/spec/webdrivers/chromedriver_spec.rb +257 -243
- data/spec/webdrivers/geckodriver_spec.rb +210 -210
- data/spec/webdrivers/i_edriver_spec.rb +192 -192
- data/spec/webdrivers/ms_webdriver_spec.rb +30 -30
- data/spec/webdrivers_proxy_support_spec.rb +53 -53
- data/webdrivers.gemspec +31 -31
- metadata +4 -11
data/spec/spec_helper.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
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
|
-
config.expect_with :rspec do |expectations|
|
13
|
-
expectations.syntax = :expect
|
14
|
-
end
|
15
|
-
config.mock_with :rspec do |mocks|
|
16
|
-
mocks.verify_partial_doubles = true
|
17
|
-
end
|
18
|
-
end
|
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
|
+
config.expect_with :rspec do |expectations|
|
13
|
+
expectations.syntax = :expect
|
14
|
+
end
|
15
|
+
config.mock_with :rspec do |mocks|
|
16
|
+
mocks.verify_partial_doubles = true
|
17
|
+
end
|
18
|
+
end
|
@@ -1,243 +1,257 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Webdrivers::Chromedriver do
|
6
|
-
let(:chromedriver) { described_class }
|
7
|
-
|
8
|
-
before
|
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
|
-
allow(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
allow(
|
47
|
-
allow(chromedriver).to receive(:
|
48
|
-
allow(chromedriver).to receive(:
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
expect
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'raises ConnectionError when offline, and
|
56
|
-
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
|
57
|
-
allow(chromedriver).to receive(:exists?).and_return(
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
expect
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
chromedriver.update
|
87
|
-
|
88
|
-
expect(chromedriver.current_version).
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
allow(
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
allow(
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
'
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
'to
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
Webdrivers::
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
allow(Webdrivers
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
expect(
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
it '
|
210
|
-
chromedriver.
|
211
|
-
|
212
|
-
chromedriver.
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Webdrivers::Chromedriver do
|
6
|
+
let(:chromedriver) { described_class }
|
7
|
+
|
8
|
+
before { chromedriver.remove }
|
9
|
+
|
10
|
+
describe '#update' do
|
11
|
+
context 'when evaluating #correct_binary?' do
|
12
|
+
it 'does not download when latest version and current version match' do
|
13
|
+
allow(chromedriver).to receive(:latest_version).and_return(Gem::Version.new('72.0.0'))
|
14
|
+
allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('72.0.0'))
|
15
|
+
|
16
|
+
chromedriver.update
|
17
|
+
|
18
|
+
expect(chromedriver.send(:exists?)).to be false
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not download when offline, binary exists and is less than v70' do
|
22
|
+
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
|
23
|
+
allow(chromedriver).to receive(:exists?).and_return(true)
|
24
|
+
allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new(69))
|
25
|
+
|
26
|
+
chromedriver.update
|
27
|
+
|
28
|
+
expect(File.exist?(chromedriver.driver_path)).to be false
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'does not download when offline, binary exists and matches major browser version' do
|
32
|
+
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
|
33
|
+
allow(chromedriver).to receive(:exists?).and_return(true)
|
34
|
+
allow(chromedriver).to receive(:chrome_version).and_return(Gem::Version.new('73.0.3683.68'))
|
35
|
+
allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('73.0.3683.20'))
|
36
|
+
|
37
|
+
chromedriver.update
|
38
|
+
|
39
|
+
expect(File.exist?(chromedriver.driver_path)).to be false
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'does not download when get raises exception, binary exists and matches major browser version' do
|
43
|
+
client_error = instance_double(Net::HTTPNotFound, class: Net::HTTPNotFound, code: 404, message: '')
|
44
|
+
|
45
|
+
allow(Webdrivers::Network).to receive(:get_response).and_return(client_error)
|
46
|
+
allow(chromedriver).to receive(:exists?).and_return(true)
|
47
|
+
allow(chromedriver).to receive(:chrome_version).and_return(Gem::Version.new('73.0.3683.68'))
|
48
|
+
allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('73.0.3683.20'))
|
49
|
+
|
50
|
+
chromedriver.update
|
51
|
+
|
52
|
+
expect(File.exist?(chromedriver.driver_path)).to be false
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'raises ConnectionError when offline, and binary does not match major browser version' do
|
56
|
+
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
|
57
|
+
allow(chromedriver).to receive(:exists?).and_return(true)
|
58
|
+
allow(chromedriver).to receive(:chrome_version).and_return(Gem::Version.new('73.0.3683.68'))
|
59
|
+
allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('72.0.0.0'))
|
60
|
+
|
61
|
+
msg = %r{Can not reach https://chromedriver.storage.googleapis.com}
|
62
|
+
expect { chromedriver.update }.to raise_error(Webdrivers::ConnectionError, msg)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'raises ConnectionError when offline, and no binary exists' do
|
66
|
+
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
|
67
|
+
allow(chromedriver).to receive(:exists?).and_return(false)
|
68
|
+
|
69
|
+
msg = %r{Can not reach https://chromedriver.storage.googleapis.com}
|
70
|
+
expect { chromedriver.update }.to raise_error(Webdrivers::ConnectionError, msg)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when correct binary is found' do
|
75
|
+
before { allow(chromedriver).to receive(:correct_binary?).and_return(true) }
|
76
|
+
|
77
|
+
it 'does not download' do
|
78
|
+
chromedriver.update
|
79
|
+
|
80
|
+
expect(chromedriver.current_version).to be_nil
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'does not raise exception if offline' do
|
84
|
+
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
|
85
|
+
|
86
|
+
chromedriver.update
|
87
|
+
|
88
|
+
expect(chromedriver.current_version).to be_nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when correct binary is not found' do
|
93
|
+
before { allow(chromedriver).to receive(:correct_binary?).and_return(false) }
|
94
|
+
|
95
|
+
it 'downloads binary' do
|
96
|
+
chromedriver.update
|
97
|
+
|
98
|
+
expect(chromedriver.current_version).not_to be_nil
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'raises ConnectionError if offline' do
|
102
|
+
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
|
103
|
+
|
104
|
+
msg = %r{Can not reach https://chromedriver.storage.googleapis.com/}
|
105
|
+
expect { chromedriver.update }.to raise_error(Webdrivers::ConnectionError, msg)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'makes a network call if cached driver does not match the browser' do
|
110
|
+
Webdrivers::System.cache_version('chromedriver', '71.0.3578.137')
|
111
|
+
allow(chromedriver).to receive(:chrome_version).and_return(Gem::Version.new('73.0.3683.68'))
|
112
|
+
allow(Webdrivers::Network).to receive(:get).and_return('73.0.3683.68')
|
113
|
+
allow(Webdrivers::System).to receive(:download)
|
114
|
+
|
115
|
+
chromedriver.update
|
116
|
+
|
117
|
+
expect(Webdrivers::Network).to have_received(:get).twice
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#current_version' do
|
122
|
+
it 'returns nil if binary does not exist on the system' do
|
123
|
+
allow(chromedriver).to receive(:driver_path).and_return('')
|
124
|
+
|
125
|
+
expect(chromedriver.current_version).to be_nil
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'returns a Gem::Version instance if binary is on the system' do
|
129
|
+
allow(chromedriver).to receive(:exists?).and_return(true)
|
130
|
+
allow(Webdrivers::System).to receive(:call)
|
131
|
+
.with("#{chromedriver.driver_path} --version")
|
132
|
+
.and_return '71.0.3578.137'
|
133
|
+
|
134
|
+
expect(chromedriver.current_version).to eq Gem::Version.new('71.0.3578.137')
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#latest_version' do
|
139
|
+
it 'returns 2.41 if the browser version is less than 70' do
|
140
|
+
allow(chromedriver).to receive(:chrome_version).and_return('69.0.0')
|
141
|
+
|
142
|
+
expect(chromedriver.latest_version).to eq(Gem::Version.new('2.41'))
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'returns the correct point release for a production version greater than 70' do
|
146
|
+
allow(chromedriver).to receive(:chrome_version).and_return '71.0.3578.9999'
|
147
|
+
|
148
|
+
expect(chromedriver.latest_version).to eq Gem::Version.new('71.0.3578.137')
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'raises VersionError for beta version' do
|
152
|
+
allow(chromedriver).to receive(:chrome_version).and_return('100.0.0')
|
153
|
+
msg = 'Unable to find latest point release version for 100.0.0. '\
|
154
|
+
'You appear to be using a non-production version of Chrome. '\
|
155
|
+
'Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` '\
|
156
|
+
'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
|
157
|
+
|
158
|
+
expect { chromedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'raises VersionError for unknown version' do
|
162
|
+
allow(chromedriver).to receive(:chrome_version).and_return('72.0.9999.0000')
|
163
|
+
msg = 'Unable to find latest point release version for 72.0.9999. '\
|
164
|
+
'Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` '\
|
165
|
+
'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
|
166
|
+
|
167
|
+
expect { chromedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'raises ConnectionError when offline' do
|
171
|
+
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
|
172
|
+
|
173
|
+
msg = %r{^Can not reach https://chromedriver.storage.googleapis.com}
|
174
|
+
expect { chromedriver.latest_version }.to raise_error(Webdrivers::ConnectionError, msg)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'creates cached file' do
|
178
|
+
allow(Webdrivers::Network).to receive(:get).and_return('71.0.3578.137')
|
179
|
+
|
180
|
+
chromedriver.latest_version
|
181
|
+
expect(File.exist?("#{Webdrivers::System.install_dir}/chromedriver.version")).to eq true
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'does not make network call if cache is valid' do
|
185
|
+
allow(Webdrivers).to receive(:cache_time).and_return(3600)
|
186
|
+
Webdrivers::System.cache_version('chromedriver', '71.0.3578.137')
|
187
|
+
allow(Webdrivers::Network).to receive(:get)
|
188
|
+
|
189
|
+
expect(chromedriver.latest_version).to eq Gem::Version.new('71.0.3578.137')
|
190
|
+
|
191
|
+
expect(Webdrivers::Network).not_to have_received(:get)
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'makes a network call if cache is expired' do
|
195
|
+
Webdrivers::System.cache_version('chromedriver', '71.0.3578.137')
|
196
|
+
allow(Webdrivers::Network).to receive(:get).and_return('73.0.3683.68')
|
197
|
+
allow(Webdrivers::System).to receive(:valid_cache?)
|
198
|
+
|
199
|
+
expect(chromedriver.latest_version).to eq Gem::Version.new('73.0.3683.68')
|
200
|
+
|
201
|
+
expect(Webdrivers::Network).to have_received(:get)
|
202
|
+
expect(Webdrivers::System).to have_received(:valid_cache?)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe '#required_version=' do
|
207
|
+
after { chromedriver.required_version = nil }
|
208
|
+
|
209
|
+
it 'returns the version specified as a Float' do
|
210
|
+
chromedriver.required_version = 73.0
|
211
|
+
|
212
|
+
expect(chromedriver.required_version).to eq Gem::Version.new('73.0')
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'returns the version specified as a String' do
|
216
|
+
chromedriver.required_version = '73.0'
|
217
|
+
|
218
|
+
expect(chromedriver.required_version).to eq Gem::Version.new('73.0')
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe '#remove' do
|
223
|
+
it 'removes existing chromedriver' do
|
224
|
+
chromedriver.update
|
225
|
+
|
226
|
+
chromedriver.remove
|
227
|
+
expect(chromedriver.current_version).to be_nil
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'does not raise exception if no chromedriver found' do
|
231
|
+
expect { chromedriver.remove }.not_to raise_error
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe '#install_dir' do
|
236
|
+
it 'uses ~/.webdrivers as default value' do
|
237
|
+
expect(Webdrivers::System.install_dir).to include('.webdriver')
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'uses provided value' do
|
241
|
+
begin
|
242
|
+
install_dir = File.expand_path(File.join(ENV['HOME'], '.webdrivers2'))
|
243
|
+
Webdrivers.install_dir = install_dir
|
244
|
+
|
245
|
+
expect(Webdrivers::System.install_dir).to eq install_dir
|
246
|
+
ensure
|
247
|
+
Webdrivers.install_dir = nil
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe '#driver_path' do
|
253
|
+
it 'returns full location of binary' do
|
254
|
+
expect(chromedriver.driver_path).to match("#{File.join(ENV['HOME'])}/.webdrivers/chromedriver")
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|