Skip to content

Commit

Permalink
Implement PR #131 for Edge
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jun 25, 2019
1 parent a118010 commit 84fb031
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/webdrivers/edge_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class EdgeFinder
class << self
def version
location = Selenium::WebDriver::EdgeChrome.path || send("#{System.platform}_location")
version = send("#{System.platform}_version", location)
version = send("#{System.platform}_version", System.escape_path(location))

raise VersionError, 'Failed to find Edge binary or its version.' if version.nil? || version.empty?

Expand All @@ -21,7 +21,12 @@ def win_location
directories.each do |dir|
envs.each do |root|
option = "#{ENV[root]}\\#{dir}\\#{file}"
return option if File.exist?(option)
next unless File.exist?(option)

# Escape space and parenthesis with backticks.
option = option.gsub(/([\s()])/, '`\1') if RUBY_PLATFORM == 'java'

return option
end
end
end
Expand Down Expand Up @@ -49,11 +54,11 @@ def win_version(location)
end

def linux_version(location)
System.call("#{Shellwords.escape location} --product-version")&.strip
System.call("#{location} --product-version")&.strip
end

def mac_version(location)
System.call("#{Shellwords.escape location} --version")&.strip
System.call("#{location} --version")&.strip
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion spec/webdrivers/edgedriver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@

describe '#driver_path' do
it 'returns full location of binary' do
expect(edgedriver.driver_path).to match("#{File.join(ENV['HOME'])}/.webdrivers/msedgedriver")
expected_bin = "msedgedriver#{'.exe' if Selenium::WebDriver::Platform.windows?}"
expected_path = Webdrivers::System.escape_path("#{File.join(ENV['HOME'])}/.webdrivers/#{expected_bin}")
expect(edgedriver.driver_path).to eq(expected_path)
end
end
end

0 comments on commit 84fb031

Please sign in to comment.