Skip to content

Commit 5d7eb2a

Browse files
committed
rb - update Safari and safaridriver paths
1 parent f13c1c0 commit 5d7eb2a

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

rb/lib/selenium/webdriver/safari.rb

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ module Selenium
2424
module WebDriver
2525
module Safari
2626
MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
27-
Unable to find safari extension. Please download the file from
28-
http://www.seleniumhq.org/download/ and place it
29-
somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/SafariDriver.
27+
Unable to find Apple's safaridriver which comes with Safari 10.
28+
More info at https://webkit.org/blog/6900/webdriver-support-in-safari-10/
3029
ERROR
3130

3231
class << self
@@ -36,22 +35,10 @@ def path=(path)
3635
end
3736

3837
def path
39-
@path ||= (
40-
path = case Platform.os
41-
when :windows
42-
Platform.find_in_program_files('Safari\\Safari.exe')
43-
when :macosx
44-
'/Applications/Safari.app/Contents/MacOS/Safari'
45-
else
46-
Platform.find_binary('Safari')
47-
end
48-
49-
unless File.file?(path) && File.executable?(path)
50-
raise Error::WebDriverError, MISSING_TEXT
51-
end
52-
53-
path
54-
)
38+
@path ||= '/Applications/Safari.app/Contents/MacOS/Safari'
39+
return @path if File.file?(@path) && File.executable?(@path)
40+
raise Error::WebDriverError, 'Safari is only supported on Mac' unless Platform.os == :macosx
41+
raise Error::WebDriverError, 'Unable to find Safari'
5542
end
5643

5744
def resource_path
@@ -64,7 +51,9 @@ def driver_path=(path)
6451
end
6552

6653
def driver_path
67-
@driver_path || '/usr/bin/safaridriver'
54+
@driver_path ||= '/usr/bin/safaridriver'
55+
return @driver_path if File.file?(@driver_path) && File.executable?(@driver_path)
56+
raise Error::WebDriverError, MISSING_TEXT
6857
end
6958
end
7059
end # Safari

0 commit comments

Comments
 (0)