Skip to content

Commit 850e910

Browse files
committed
rename Edge classes to support Selenium 4 beta
1 parent 6eb6027 commit 850e910

File tree

5 files changed

+18
-37
lines changed

5 files changed

+18
-37
lines changed

gemfiles/Gemfile.edge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source 'https://rubygems.org'
44

55
# Specify your gem's dependencies in webdrivers.gemspec
66
gemspec path: '..'
7-
gem 'selenium-webdriver', github: 'seleniumhq/selenium', branch: 'trunk', glob: 'rb/*.gemspec'
7+
gem 'selenium-webdriver', '>= 4.0.0.beta1'

lib/webdrivers/edge_finder.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def location
2424
private
2525

2626
def user_defined_location
27-
if Selenium::WebDriver::EdgeChrome.path
28-
Webdrivers.logger.debug "Selenium::WebDriver::EdgeChrome.path: #{Selenium::WebDriver::EdgeChrome.path}"
29-
return Selenium::WebDriver::EdgeChrome.path
27+
if Selenium::WebDriver::Edge.path
28+
Webdrivers.logger.debug "Selenium::WebDriver::Edge.path: #{Selenium::WebDriver::Edge.path}"
29+
return Selenium::WebDriver::Edge.path
3030
end
3131

32-
return if ENV['WD_EDGE_CHROME_PATH'].nil?
32+
return if ENV['WD_EDGE_PATH'].nil?
3333

34-
Webdrivers.logger.debug "WD_EDGE_CHROME_PATH: #{ENV['WD_EDGE_CHROME_PATH']}"
35-
ENV['WD_EDGE_CHROME_PATH']
34+
Webdrivers.logger.debug "WD_EDGE_PATH: #{ENV['WD_EDGE_PATH']}"
35+
ENV['WD_EDGE_PATH']
3636
end
3737

3838
def win_location

lib/webdrivers/edgedriver.rb

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,4 @@ def download_url
111111
end
112112
end
113113

114-
if defined? Selenium::WebDriver::EdgeChrome
115-
if ::Selenium::WebDriver::Service.respond_to? :driver_path=
116-
::Selenium::WebDriver::EdgeChrome::Service.driver_path = proc { ::Webdrivers::Edgedriver.update }
117-
else
118-
# v3.141.0 and lower
119-
module Selenium
120-
module WebDriver
121-
module EdgeChrome
122-
def self.driver_path
123-
@driver_path ||= Webdrivers::Edgedriver.update
124-
end
125-
end
126-
end
127-
end
128-
end
129-
end
114+
::Selenium::WebDriver::Edge::Service.driver_path = proc { ::Webdrivers::Edgedriver.update }

spec/webdrivers/edge_finder_spec.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
let(:edge_finder) { described_class }
77

88
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
9-
# Skip these tests if version of selenium-webdriver being tested with doesn't
10-
# have Chromium based Edge support
11-
unless defined?(Selenium::WebDriver::EdgeChrome)
9+
if Selenium::WebDriver::VERSION[0].to_i < 4
1210
skip "The current selenium-webdriver doesn't include Chromium based Edge support"
1311
end
1412
end
@@ -20,29 +18,29 @@
2018
end
2119

2220
context 'when the user provides a path to the Edge binary' do
23-
it 'uses Selenium::WebDriver::EdgeChrome.path when it is defined' do
24-
Selenium::WebDriver::EdgeChrome.path = edge_finder.location
21+
it 'uses Selenium::WebDriver::Edge.path when it is defined' do
22+
Selenium::WebDriver::Edge.path = edge_finder.location
2523
locations = %i[win_location mac_location linux_location]
2624
allow(edge_finder).to receive_messages(locations)
2725

2826
expect(edge_finder.version).not_to be_nil
2927
locations.each { |loc| expect(edge_finder).not_to have_received(loc) }
3028
end
3129

32-
it "uses ENV['WD_EDGE_CHROME_PATH'] when it is defined" do
33-
allow(ENV).to receive(:[]).with('WD_EDGE_CHROME_PATH').and_return(edge_finder.location)
30+
it "uses ENV['WD_EDGE_PATH'] when it is defined" do
31+
allow(ENV).to receive(:[]).with('WD_EDGE_PATH').and_return(edge_finder.location)
3432
locations = %i[win_location mac_location linux_location]
3533
allow(edge_finder).to receive_messages(locations)
3634

3735
expect(edge_finder.version).not_to be_nil
3836
locations.each { |loc| expect(edge_finder).not_to have_received(loc) }
3937
end
4038

41-
it 'uses Selenium::WebDriver::EdgeChrome.path over WD_EDGE_CHROME_PATH' do
42-
Selenium::WebDriver::EdgeChrome.path = edge_finder.location
43-
allow(ENV).to receive(:[]).with('WD_EDGE_CHROME_PATH').and_return('my_wd_chrome_path')
39+
it 'uses Selenium::WebDriver::Edge.path over WD_EDGE_PATH' do
40+
Selenium::WebDriver::Edge.path = edge_finder.location
41+
allow(ENV).to receive(:[]).with('WD_EDGE_PATH').and_return('my_wd_chrome_path')
4442
expect(edge_finder.version).not_to be_nil
45-
expect(ENV).not_to have_received(:[]).with('WD_EDGE_CHROME_PATH')
43+
expect(ENV).not_to have_received(:[]).with('WD_EDGE_PATH')
4644
end
4745
end
4846

spec/webdrivers/edgedriver_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
let(:edgedriver) { described_class }
77

88
before(:all) do # rubocop:disable RSpec/BeforeAfterAll
9-
# Skip these tests if version of selenium-webdriver being tested with doesn't
10-
# have Chromium based Edge support
11-
unless defined?(Selenium::WebDriver::EdgeChrome)
9+
if Selenium::WebDriver::VERSION[0].to_i < 4
1210
skip "The current selenium-webdriver doesn't include Chromium based Edge support"
1311
end
1412
end

0 commit comments

Comments
 (0)