Skip to content

Commit

Permalink
add support for Microsoft Edge on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Sep 19, 2022
1 parent f37cc82 commit f05f362
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
23 changes: 11 additions & 12 deletions lib/webdrivers/edge_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ def mac_location
end

def linux_location
# directories = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin /opt/google/chrome]
# files = %w[microsoft-edge] # Based on Microsoft Edge 89.0.760.0 dev
#
# directories.each do |dir|
# files.each do |file|
# option = "#{dir}/#{file}"
# return option if File.exist?(option)
# end
# end
#
# nil
raise 'Default location not yet known'
directories = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin /opt/microsoft/edge]
files = %w[microsoft-edge microsoft-edge-beta microsoft-edge-dev]

directories.each do |dir|
files.each do |file|
option = "#{dir}/#{file}"
return option if File.exist?(option)
end
end

nil
end

def win_version(location)
Expand Down
9 changes: 2 additions & 7 deletions lib/webdrivers/edgedriver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def browser_version
#
# @return [String]
def base_url
# 'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/'
'https://msedgedriver.azureedge.net/'
'https://msedgedriver.azureedge.net'
end

private
Expand Down Expand Up @@ -76,14 +75,10 @@ def apple_m1_compatible?(driver_version)
false
end

def linux_compatible?(driver_version)
System.platform == 'linux' && driver_version >= normalize_version('89.0.731.0')
end

def driver_filename(driver_version)
if System.platform == 'win' || System.wsl_v1?
"win#{System.bitsize}" # 32 or 64-bit
elsif linux_compatible?(driver_version)
elsif System.platform == 'linux'
'linux64'
elsif System.platform == 'mac'
# Determine M1 or Intel architecture
Expand Down
13 changes: 6 additions & 7 deletions spec/webdrivers/edgedriver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
let(:edgedriver) { described_class }

before do
skip 'Edge is not yet supported on Linux' if Webdrivers::System.platform == 'linux'
edgedriver.remove
end

Expand Down Expand Up @@ -123,19 +122,19 @@

context 'when required version is 0' do
it 'downloads the latest version' do
allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('77.0.207.0'))
allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('98.0.1089.1'))
edgedriver.required_version = 0
edgedriver.update
expect(edgedriver.current_version.version).to eq('77.0.207.0')
expect(edgedriver.current_version.version).to eq('98.0.1089.1')
end
end

context 'when required version is nil' do
it 'downloads the latest version' do
allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('77.0.207.0'))
allow(edgedriver).to receive(:latest_version).and_return(Gem::Version.new('98.0.1089.1'))
edgedriver.required_version = nil
edgedriver.update
expect(edgedriver.current_version.version).to eq('77.0.207.0')
expect(edgedriver.current_version.version).to eq('98.0.1089.1')
end
end
end
Expand Down Expand Up @@ -169,7 +168,7 @@
msg = 'Unable to find latest point release version for 999.0.0. '\
'You appear to be using a non-production version of Edge. '\
'Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` '\
'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net/'
'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net'

expect { edgedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
end
Expand All @@ -178,7 +177,7 @@
allow(edgedriver).to receive(:browser_version).and_return Gem::Version.new('77.0.9999')
msg = 'Unable to find latest point release version for 77.0.9999. '\
'Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` '\
'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net/'
'to a known edgedriver version: Can not reach https://msedgedriver.azureedge.net'

expect { edgedriver.latest_version }.to raise_exception(Webdrivers::VersionError, msg)
end
Expand Down

0 comments on commit f05f362

Please sign in to comment.