webdrivers 4.0.1 → 5.2.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.
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'webdrivers'
4
3
  require 'rails'
5
4
 
6
5
  module Webdrivers
@@ -2,6 +2,13 @@
2
2
 
3
3
  require 'rubygems/package'
4
4
  require 'zip'
5
+ require 'English'
6
+
7
+ # validate zip entry sizes to avoid zip bombs
8
+ # see https://github.com/rubyzip/rubyzip#size-validation
9
+ # and https://github.com/rubyzip/rubyzip/pull/403 for further details
10
+ # this will be the default in rubyzip 2.0+
11
+ Zip.validate_entry_sizes = true
5
12
 
6
13
  module Webdrivers
7
14
  #
@@ -13,11 +20,13 @@ module Webdrivers
13
20
  max_attempts = 3
14
21
  attempts_made = 0
15
22
  delay = 0.5
16
- Webdrivers.logger.debug "Deleting #{file}"
17
23
 
18
24
  begin
19
25
  attempts_made += 1
20
- File.delete file if File.exist? file
26
+ if File.exist? file
27
+ Webdrivers.logger.debug "Deleting #{file}"
28
+ File.delete file
29
+ end
21
30
  rescue Errno::EACCES # Solves an intermittent file locking issue on Windows
22
31
  sleep(delay)
23
32
  retry if File.exist?(file) && attempts_made <= max_attempts
@@ -89,7 +98,7 @@ module Webdrivers
89
98
  when /tar\.bz2$/
90
99
  untarbz2_file(tempfile)
91
100
  when /\.zip$/
92
- unzip_file(tempfile)
101
+ unzip_file(tempfile, File.basename(target))
93
102
  else
94
103
  Webdrivers.logger.debug 'No Decompression needed'
95
104
  FileUtils.cp(tempfile, File.join(Dir.pwd, file_name))
@@ -114,19 +123,17 @@ module Webdrivers
114
123
  end
115
124
  end
116
125
 
117
- def unzip_file(filename)
126
+ def unzip_file(filename, driver_name)
118
127
  Webdrivers.logger.debug "Decompressing #{filename}"
119
128
 
120
129
  Zip::File.open(filename) do |zip_file|
121
- zip_file.each do |f|
122
- @top_path ||= f.name
123
- f_path = File.join(Dir.pwd, f.name)
124
- delete(f_path)
125
- FileUtils.mkdir_p(File.dirname(f_path)) unless File.exist?(File.dirname(f_path))
126
- zip_file.extract(f, f_path)
127
- end
130
+ driver = zip_file.get_entry(driver_name)
131
+ f_path = File.join(Dir.pwd, driver.name)
132
+ delete(f_path)
133
+ FileUtils.mkdir_p(File.dirname(f_path)) unless File.exist?(File.dirname(f_path))
134
+ zip_file.extract(driver, f_path)
128
135
  end
129
- @top_path
136
+ driver_name
130
137
  end
131
138
 
132
139
  def platform
@@ -141,19 +148,49 @@ module Webdrivers
141
148
  end
142
149
  end
143
150
 
151
+ def apple_m1_architecture?
152
+ if platform == 'mac' && RUBY_PLATFORM.include?('arm64-darwin')
153
+ Webdrivers.logger.debug 'Apple architecture: M1 (arm64-darwin)'
154
+ return true
155
+ end
156
+
157
+ Webdrivers.logger.debug 'Apple architecture: Intel (mac64)'
158
+ false
159
+ end
160
+
161
+ # @return [TrueClass, FalseClass]
162
+ def wsl_v1?
163
+ platform == 'linux' && File.open('/proc/version').read.include?('Microsoft')
164
+ end
165
+
166
+ # @param [String] path
167
+ # @return [String]
168
+ def to_win32_path(path)
169
+ return path if /[a-z]:\\/iu.match?(path)
170
+
171
+ call("wslpath -w '#{path}'").chomp
172
+ end
173
+
174
+ # @param [String] path
175
+ # @return [String]
176
+ def to_wsl_path(path)
177
+ call("wslpath -u '#{path}'").chomp
178
+ end
179
+
144
180
  def bitsize
145
181
  Selenium::WebDriver::Platform.bitsize
146
182
  end
147
183
 
148
- def call(cmd)
184
+ def call(process, arg = nil)
185
+ cmd = arg ? [process, arg] : process # Windows provides powershell command (process) only, no args.
149
186
  Webdrivers.logger.debug "making System call: #{cmd}"
150
- `#{cmd}`
151
- end
152
-
153
- def escape_path(path)
154
- return path.tr('/', '\\') if platform == 'win' # Windows
187
+ p = IO.popen(cmd)
188
+ out = p.read
189
+ p.close
190
+ raise "Failed to make system call: #{cmd}" unless $CHILD_STATUS.success?
155
191
 
156
- Shellwords.escape(path) # Linux and macOS
192
+ Webdrivers.logger.debug "System call returned: #{out}"
193
+ out
157
194
  end
158
195
  end
159
196
  end
@@ -19,8 +19,6 @@ namespace :webdrivers do
19
19
  desc 'Remove and download updated chromedriver if necessary'
20
20
  task :update, [:version] do |_, args|
21
21
  args.with_defaults(version: 0)
22
- Webdrivers.cache_time = ENV.fetch('WD_CACHE_TIME', 86_400)
23
- Webdrivers.install_dir = ENV.fetch('WD_INSTALL_DIR', nil)
24
22
  Webdrivers::Chromedriver.required_version = args.version
25
23
  Webdrivers::Chromedriver.update
26
24
  Webdrivers.logger.info "Updated to chromedriver #{Webdrivers::Chromedriver.current_version}"
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :webdrivers do
4
+ require 'webdrivers/edgedriver'
5
+
6
+ namespace :edgedriver do
7
+ Webdrivers.logger.level = :info
8
+
9
+ desc 'Print current edgedriver version'
10
+ task :version do
11
+ gem_ver = Webdrivers::Edgedriver.current_version
12
+ if gem_ver
13
+ Webdrivers.logger.info "edgedriver #{gem_ver.version}"
14
+ else
15
+ Webdrivers.logger.warn 'No existing edgedriver found.'
16
+ end
17
+ end
18
+
19
+ desc 'Remove and download updated edgedriver if necessary'
20
+ task :update, [:version] do |_, args|
21
+ args.with_defaults(version: 0)
22
+ Webdrivers::Edgedriver.required_version = args.version
23
+ Webdrivers::Edgedriver.update
24
+ Webdrivers.logger.info "Updated to edgedriver #{Webdrivers::Edgedriver.current_version}"
25
+ end
26
+
27
+ desc 'Force remove edgedriver'
28
+ task :remove do
29
+ unless File.exist? Webdrivers::Edgedriver.driver_path
30
+ Webdrivers.logger.info 'No existing edgedriver to remove.'
31
+ next # Return early
32
+ end
33
+
34
+ cur_version = Webdrivers::Edgedriver.current_version
35
+ Webdrivers::Edgedriver.remove
36
+
37
+ if File.exist? Webdrivers::Edgedriver.driver_path # Failed for some reason
38
+ Webdrivers.logger.error 'Failed to remove edgedriver. Please try removing manually.'
39
+ else
40
+ Webdrivers.logger.info "Removed edgedriver #{cur_version}."
41
+ end
42
+ end
43
+ end
44
+ end
@@ -19,8 +19,6 @@ namespace :webdrivers do
19
19
  desc 'Remove and download updated geckodriver if necessary'
20
20
  task :update, [:version] do |_, args|
21
21
  args.with_defaults(version: 0)
22
- Webdrivers.cache_time = ENV.fetch('WD_CACHE_TIME', 86_400)
23
- Webdrivers.install_dir = ENV.fetch('WD_INSTALL_DIR', nil)
24
22
  Webdrivers::Geckodriver.required_version = args.version
25
23
  Webdrivers::Geckodriver.update
26
24
  Webdrivers.logger.info "Updated to geckodriver #{Webdrivers::Geckodriver.current_version}"
@@ -19,8 +19,6 @@ namespace :webdrivers do
19
19
  desc 'Remove and download updated IEDriverServer if necessary'
20
20
  task :update, [:version] do |_, args|
21
21
  args.with_defaults(version: 0)
22
- Webdrivers.cache_time = ENV.fetch('WD_CACHE_TIME', 86_400)
23
- Webdrivers.install_dir = ENV.fetch('WD_INSTALL_DIR', nil)
24
22
  Webdrivers::IEdriver.required_version = args.version
25
23
  Webdrivers::IEdriver.update
26
24
  Webdrivers.logger.info "Updated to IEDriverServer #{Webdrivers::IEdriver.current_version}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Webdrivers
4
- VERSION = '4.0.1'
4
+ VERSION = '5.2.0'
5
5
  end
data/lib/webdrivers.rb CHANGED
@@ -2,5 +2,6 @@
2
2
 
3
3
  require 'webdrivers/chromedriver'
4
4
  require 'webdrivers/geckodriver'
5
+ require 'webdrivers/edgedriver'
5
6
  require 'webdrivers/iedriver'
6
7
  require 'webdrivers/railtie' if defined?(Rails)
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Webdrivers::ChromeFinder do
6
+ let(:chrome_finder) { described_class }
7
+
8
+ context 'when the user relies on the gem to figure out the location of Chrome' do
9
+ it 'determines the location correctly based on the current OS' do
10
+ expect { chrome_finder.location }.not_to raise_error
11
+ end
12
+ end
13
+
14
+ context 'when the user provides a path to the Chrome binary' do
15
+ it 'uses Selenium::WebDriver::Chrome.path when it is defined' do
16
+ Selenium::WebDriver::Chrome.path = chrome_finder.location
17
+ locations = %i[win_location mac_location linux_location]
18
+ allow(chrome_finder).to receive_messages(locations)
19
+
20
+ expect(chrome_finder.version).not_to be_nil
21
+ locations.each { |loc| expect(chrome_finder).not_to have_received(loc) }
22
+ end
23
+ end
24
+
25
+ it "uses ENV['WD_CHROME_PATH'] when it is defined" do
26
+ allow(ENV).to receive(:[]).with('WD_CHROME_PATH').and_return(chrome_finder.location)
27
+ locations = %i[win_location mac_location linux_location]
28
+ allow(chrome_finder).to receive_messages(locations)
29
+
30
+ expect(chrome_finder.version).not_to be_nil
31
+ locations.each { |loc| expect(chrome_finder).not_to have_received(loc) }
32
+ end
33
+
34
+ it 'uses Selenium::WebDriver::Chrome.path over WD_CHROME_PATH' do
35
+ Selenium::WebDriver::Chrome.path = chrome_finder.location
36
+ allow(ENV).to receive(:[]).with('WD_CHROME_PATH').and_return('my_wd_chrome_path')
37
+ expect(chrome_finder.version).not_to be_nil
38
+ expect(ENV).not_to have_received(:[]).with('WD_CHROME_PATH')
39
+ end
40
+
41
+ context 'when Chrome is not installed' do
42
+ it 'raises BrowserNotFound' do
43
+ locations = %i[win_location mac_location linux_location]
44
+ allow(chrome_finder).to receive_messages(locations)
45
+ allow(chrome_finder).to receive(:user_defined_location).and_return(nil)
46
+
47
+ expect { chrome_finder.version }.to raise_error(Webdrivers::BrowserNotFound)
48
+ end
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_v1?).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
103
+ end
@@ -31,7 +31,7 @@ describe Webdrivers::Chromedriver do
31
31
  it 'does not download when offline, binary exists and matches major browser version' do
32
32
  allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
33
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'))
34
+ allow(chromedriver).to receive(:browser_version).and_return(Gem::Version.new('73.0.3683.68'))
35
35
  allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('73.0.3683.20'))
36
36
 
37
37
  chromedriver.update
@@ -44,7 +44,7 @@ describe Webdrivers::Chromedriver do
44
44
 
45
45
  allow(Webdrivers::Network).to receive(:get_response).and_return(client_error)
46
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'))
47
+ allow(chromedriver).to receive(:browser_version).and_return(Gem::Version.new('73.0.3683.68'))
48
48
  allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('73.0.3683.20'))
49
49
 
50
50
  chromedriver.update
@@ -55,7 +55,7 @@ describe Webdrivers::Chromedriver do
55
55
  it 'raises ConnectionError when offline, and binary does not match major browser version' do
56
56
  allow(Net::HTTP).to receive(:get_response).and_raise(SocketError)
57
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'))
58
+ allow(chromedriver).to receive(:browser_version).and_return(Gem::Version.new('73.0.3683.68'))
59
59
  allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('72.0.0.0'))
60
60
 
61
61
  msg = %r{Can not reach https://chromedriver.storage.googleapis.com}
@@ -106,15 +106,16 @@ describe Webdrivers::Chromedriver do
106
106
  end
107
107
  end
108
108
 
109
- it 'makes a network call if cached driver does not match the browser' do
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(:chrome_version).and_return(Gem::Version.new('73.0.3683.68'))
111
+ allow(chromedriver).to receive(:current_version).and_return(Gem::Version.new('71.0.3578.137'))
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).once
118
+ expect(Webdrivers::Network).to have_received(:get).twice
118
119
  end
119
120
 
120
121
  context 'when required version is 0' do
@@ -146,7 +147,7 @@ describe Webdrivers::Chromedriver do
146
147
  it 'returns a Gem::Version instance if binary is on the system' do
147
148
  allow(chromedriver).to receive(:exists?).and_return(true)
148
149
  allow(Webdrivers::System).to receive(:call)
149
- .with("#{chromedriver.driver_path} --version")
150
+ .with(chromedriver.driver_path, '--version')
150
151
  .and_return '71.0.3578.137'
151
152
 
152
153
  expect(chromedriver.current_version).to eq Gem::Version.new('71.0.3578.137')
@@ -155,20 +156,20 @@ 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(:chrome_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(:chrome_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(:chrome_version).and_return('100.0.0')
171
- msg = 'Unable to find latest point release version for 100.0.0. '\
171
+ allow(chromedriver).to receive(:browser_version).and_return Gem::Version.new('999.0.0')
172
+ msg = 'Unable to find latest point release version for 999.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>` '\
174
175
  'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
@@ -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(:chrome_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 call if cache is valid' do
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 a network call if cache is expired' do
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
 
@@ -253,8 +258,19 @@ describe Webdrivers::Chromedriver do
253
258
  describe '#driver_path' do
254
259
  it 'returns full location of binary' do
255
260
  expected_bin = "chromedriver#{'.exe' if Selenium::WebDriver::Platform.windows?}"
256
- expected_path = Webdrivers::System.escape_path("#{File.join(ENV['HOME'])}/.webdrivers/#{expected_bin}")
261
+ expected_path = File.absolute_path "#{File.join(ENV['HOME'])}/.webdrivers/#{expected_bin}"
257
262
  expect(chromedriver.driver_path).to eq(expected_path)
258
263
  end
259
264
  end
265
+
266
+ describe '#browser_version' do
267
+ it 'returns a Gem::Version object' do
268
+ expect(chromedriver.browser_version).to be_an_instance_of(Gem::Version)
269
+ end
270
+
271
+ it 'returns currently installed Chrome version' do
272
+ allow(Webdrivers::ChromeFinder).to receive(:version).and_return('72.0.0.0')
273
+ expect(chromedriver.browser_version).to be Gem::Version.new('72.0.0.0')
274
+ end
275
+ end
260
276
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Webdrivers::EdgeFinder do
6
+ let(:edge_finder) { described_class }
7
+
8
+ before { skip 'Edge is not yet supported on Linux' if Webdrivers::System.platform == 'linux' }
9
+
10
+ context 'when the user relies on the gem to figure out the location of Edge' do
11
+ it 'determines the location correctly based on the current OS' do
12
+ expect { edge_finder.location }.not_to raise_error
13
+ end
14
+ end
15
+
16
+ context 'when the user provides a path to the Edge binary' do
17
+ it 'uses Selenium::WebDriver::Edge.path when it is defined' do
18
+ Selenium::WebDriver::Edge.path = edge_finder.location
19
+ locations = %i[win_location mac_location linux_location]
20
+ allow(edge_finder).to receive_messages(locations)
21
+
22
+ expect(edge_finder.version).not_to be_nil
23
+ locations.each { |loc| expect(edge_finder).not_to have_received(loc) }
24
+ end
25
+
26
+ it "uses ENV['WD_EDGE_PATH'] when it is defined" do
27
+ allow(ENV).to receive(:[]).with('WD_EDGE_PATH').and_return(edge_finder.location)
28
+ locations = %i[win_location mac_location linux_location]
29
+ allow(edge_finder).to receive_messages(locations)
30
+
31
+ expect(edge_finder.version).not_to be_nil
32
+ locations.each { |loc| expect(edge_finder).not_to have_received(loc) }
33
+ end
34
+
35
+ it 'uses Selenium::WebDriver::Edge.path over WD_EDGE_PATH' do
36
+ Selenium::WebDriver::Edge.path = edge_finder.location
37
+ allow(ENV).to receive(:[]).with('WD_EDGE_PATH').and_return('my_wd_chrome_path')
38
+ expect(edge_finder.version).not_to be_nil
39
+ expect(ENV).not_to have_received(:[]).with('WD_EDGE_PATH')
40
+ end
41
+ end
42
+
43
+ context 'when Edge is not installed' do
44
+ it 'raises BrowserNotFound' do
45
+ locations = %i[win_location mac_location linux_location]
46
+ allow(edge_finder).to receive_messages(locations)
47
+ allow(edge_finder).to receive(:user_defined_location).and_return(nil)
48
+
49
+ expect { edge_finder.version }.to raise_error(Webdrivers::BrowserNotFound)
50
+ end
51
+ end
52
+ end