webdrivers 3.8.0 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,38 +1,40 @@
1
- require 'selenium-webdriver'
2
-
3
- # v3.151.59 and higher
4
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
5
- ::Selenium::WebDriver::Chrome::Service.driver_path = proc { ::Webdrivers::Chromedriver.update }
6
- ::Selenium::WebDriver::Firefox::Service.driver_path = proc { ::Webdrivers::Geckodriver.update }
7
- ::Selenium::WebDriver::Edge::Service.driver_path = proc { ::Webdrivers::MSWebdriver.update }
8
- ::Selenium::WebDriver::IE::Service.driver_path = proc { ::Webdrivers::IEdriver.update }
9
- else
10
- # v3.141.0 and lower
11
- module Selenium
12
- module WebDriver
13
- module Chrome
14
- def self.driver_path
15
- @driver_path ||= Webdrivers::Chromedriver.update
16
- end
17
- end
18
-
19
- module Firefox
20
- def self.driver_path
21
- @driver_path ||= Webdrivers::Geckodriver.update
22
- end
23
- end
24
-
25
- module Edge
26
- def self.driver_path
27
- @driver_path ||= Webdrivers::MSWebdriver.update
28
- end
29
- end
30
-
31
- module IE
32
- def self.driver_path
33
- @driver_path ||= Webdrivers::IEdriver.update
34
- end
35
- end
36
- end
37
- end
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
- require 'simplecov'
2
- SimpleCov.start
3
-
4
- require 'rspec'
5
- require 'webdrivers'
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
- require 'spec_helper'
2
-
3
- describe Webdrivers::Chromedriver do
4
- let(:chromedriver) { described_class }
5
-
6
- it 'updates' do
7
- chromedriver.update
8
- end
9
-
10
- it 'parses chromedriver versions before 2.10' do
11
- expect(chromedriver.send(:normalize, '2.9').version).to eq '2.9'
12
- end
13
-
14
- it 'finds latest version' do
15
- old_version = Gem::Version.new('2.30')
16
- future_version = Gem::Version.new('80.00')
17
- latest_version = chromedriver.latest_version
18
-
19
- expect(latest_version).to be > old_version
20
- expect(latest_version).to be < future_version
21
- end
22
-
23
- it 'downloads latest release for current version of Chrome by default' do
24
- chromedriver.remove
25
- chromedriver.download
26
- cur_ver = chromedriver.current_version.version
27
- latest_ver = chromedriver.latest_version.version
28
- expect(cur_ver).to eq latest_ver
29
- end
30
-
31
- it 'downloads specified version by Float' do
32
- chromedriver.remove
33
- chromedriver.version = 2.29
34
- chromedriver.download
35
- expect(chromedriver.current_version.version).to include '2.29'
36
- end
37
-
38
- it 'downloads specified version by String' do
39
- chromedriver.remove
40
- chromedriver.version = '73.0.3683.68'
41
- chromedriver.download
42
- expect(chromedriver.current_version.version).to eq '73.0.3683.68'
43
- end
44
-
45
- it 'removes chromedriver' do
46
- chromedriver.remove
47
- expect(chromedriver.current_version).to be_nil
48
- end
49
-
50
- if Selenium::WebDriver::Platform.linux? && ENV['TRAVIS']
51
- # Ubuntu 14.04 (trusty) is limited to v65
52
- context 'when using a Chromium version < 70.0.3538' do
53
- before do
54
- chromedriver.remove
55
- chromedriver.version = nil
56
- Selenium::WebDriver::Chrome.path = `which chromium-browser`.strip
57
- end
58
-
59
- it 'downloads chromedriver 2.46' do
60
- chromedriver.update
61
- expect(chromedriver.current_version.version[/\d+.\d+/]).to eq('2.46')
62
- end
63
- end
64
- end
65
-
66
- # Workaround for Google Chrome when using Jruby on Windows.
67
- # @see https://github.com/titusfortner/webdrivers/issues/41
68
- if RUBY_PLATFORM == 'java' && Selenium::WebDriver::Platform.windows?
69
- context 'when using Jruby on Windows' do
70
- it 'uses Jruby specific workaround to retrieve the Google Chrome version' do
71
- chromedriver.remove
72
- chromedriver.update
73
- expect(chromedriver.current_version).not_to be_nil
74
- end
75
- end
76
- end
77
-
78
- context 'when offline' do
79
- before { allow(chromedriver).to receive(:site_available?).and_return(false) }
80
-
81
- it 'raises exception finding latest version' do
82
- expect { chromedriver.latest_version }.to raise_error(StandardError, 'Can not reach site')
83
- end
84
-
85
- it 'raises exception downloading' do
86
- expect { chromedriver.download }.to raise_error(StandardError, 'Can not reach site')
87
- end
88
- end
89
-
90
- it 'allows setting of install directory' do
91
- begin
92
- install_dir = File.expand_path(File.join(ENV['HOME'], '.webdrivers2'))
93
- Webdrivers.install_dir = install_dir
94
- expect(chromedriver.install_dir).to eq install_dir
95
- ensure
96
- Webdrivers.install_dir = nil
97
- end
98
- end
99
-
100
- it 'returns full location of binary' do
101
- install_dir = File.expand_path(File.join(ENV['HOME'], '.webdrivers'))
102
- expect(chromedriver.binary).to match %r{#{install_dir}/chromedriver}
103
- end
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
- require 'spec_helper'
2
-
3
- describe Webdrivers::Geckodriver do
4
- let(:geckodriver) { described_class }
5
-
6
- it 'raises exception if unable to get latest geckodriver and no geckodriver present' do
7
- geckodriver.remove
8
- allow(geckodriver).to receive(:desired_version).and_return(nil)
9
- msg = /^Unable to find the latest version of geckodriver(.exe)?; try downloading manually from (.*)?and place in (.*)?\.webdrivers$/
10
- expect { geckodriver.update }.to raise_exception StandardError, msg
11
- end
12
-
13
- it 'uses found version of geckodriver if latest release unable to be found' do
14
- geckodriver.download
15
- allow(geckodriver).to receive(:desired_version).and_return(nil)
16
- expect(geckodriver.update).to match(%r{\.webdrivers/geckodriver})
17
- end
18
-
19
- it 'finds latest version' do
20
- old_version = Gem::Version.new('0.17')
21
- future_version = Gem::Version.new('0.30')
22
- desired_version = geckodriver.desired_version
23
-
24
- expect(desired_version).to be > old_version
25
- expect(desired_version).to be < future_version
26
- end
27
-
28
- it 'downloads latest version by default' do
29
- geckodriver.download
30
- expect(geckodriver.current_version).to eq geckodriver.desired_version
31
- end
32
-
33
- it 'downloads specified version' do
34
- begin
35
- geckodriver.remove
36
- geckodriver.version = '0.17.0'
37
- geckodriver.download
38
- expect(geckodriver.current_version.version).to eq '0.17.0'
39
- ensure
40
- geckodriver.version = nil
41
- end
42
- end
43
-
44
- it 'removes geckodriver' do
45
- geckodriver.remove
46
- expect(geckodriver.current_version).to be_nil
47
- end
48
-
49
- context 'when offline' do
50
- before { allow(geckodriver).to receive(:site_available?).and_return(false) }
51
-
52
- it 'raises exception finding latest version' do
53
- expect { geckodriver.desired_version }.to raise_error(StandardError, 'Can not reach site')
54
- end
55
-
56
- it 'raises exception downloading' do
57
- expect { geckodriver.download }.to raise_error(StandardError, 'Can not reach site')
58
- end
59
- end
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