lib/selenium/webdriver/chrome/launcher.rb in selenium-webdriver-0.1.0 vs lib/selenium/webdriver/chrome/launcher.rb in selenium-webdriver-0.1.1
- old
+ new
@@ -6,25 +6,10 @@
class Launcher
include FileUtils
attr_reader :pid
- def self.launcher(*args)
- launcher = case Platform.os
- when :windows
- WindowsLauncher.new(*args)
- when :macosx
- MacOSXLauncher.new(*args)
- when :unix, :linux
- UnixLauncher.new(*args)
- else
- raise "unknown OS: #{Platform.os}"
- end
-
- launcher
- end
-
def initialize(opts = {})
@default_profile = opts[:default_profile]
@secure_ssl = !!opts[:secure_ssl]
end
@@ -120,48 +105,63 @@
dir
)
end
- class WindowsLauncher < Launcher
- def self.possible_paths
+ class << self
+ def possible_paths
+ case Platform.os
+ when :windows
+ windows_paths
+ when :macosx
+ macosx_paths
+ when :unix, :linux
+ unix_paths
+ else
+ raise "unknown OS: #{Platform.os}"
+ end
+ end
+
+ def unix_paths
[
- registry_path,
+ Platform.find_binary("google-chrome"),
+ Platform.find_binary("chromium"),
+ Platform.find_binary("chromium-browser"),
+ "/usr/bin/google-chrome"
+ ].compact
+ end
+
+ def macosx_paths
+ [
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
+ "#{Platform.home}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
+ ]
+ end
+
+ def windows_paths
+ [
+ windows_registry_path,
"#{ENV['USERPROFILE']}\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe",
"#{ENV['USERPROFILE']}\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe",
"#{Platform.home}\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe",
"#{Platform.home}\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe",
].compact
end
- def self.registry_path
+ def windows_registry_path
require "win32/registry"
- reg = Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe")
+ reg = Win32::Registry::HKEY_LOCAL_MACHINE.open(
+ "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe")
+
reg[""]
rescue LoadError
# older JRuby and IronRuby does not have win32/registry
nil
rescue Win32::Registry::Error
nil
end
- end
-
- class UnixLauncher < Launcher
- def self.possible_paths
- [Platform.find_binary("google-chrome"), Platform.find_binary("chromium"), "/usr/bin/google-chrome"].compact
- end
-
- end
-
- class MacOSXLauncher < UnixLauncher
- def self.possible_paths
- [
- "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
- "#{Platform.home}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
- ]
- end
- end
+ end # class << self
end # Launcher
end # Chrome
end # WebDriver
end # Selenium