Class: Selenium::WebDriver::Chrome::Launcher Private

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/selenium/webdriver/chrome/launcher.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Launcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Launcher.



11
12
13
14
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 11

def initialize(opts = {})
  @default_profile = opts[:default_profile]
  @secure_ssl = !!opts[:secure_ssl]
end

Instance Attribute Details

#pidObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 9

def pid
  @pid
end

Class Method Details

.binary_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
21
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 16

def self.binary_path
  @binary_path ||= (
    path = possible_paths.find { |f| File.exist?(f) }
    path || raise(Error::WebDriverError, "Could not find Chrome binary. Make sure Chrome is installed (OS: #{Platform.os})")
  )
end

.binary_path=(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 29

def self.binary_path=(path)
  Platform.assert_executable(path)
  @binary_path = path
end

.macosx_pathsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



135
136
137
138
139
140
141
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 135

def macosx_paths
  [
   "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
   "#{Platform.home}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
   Platform.find_binary("Google Chrome")
  ]
end

.possible_pathsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 113

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

.unix_pathsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



126
127
128
129
130
131
132
133
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 126

def unix_paths
  [
    Platform.find_binary("google-chrome"),
    Platform.find_binary("chromium"),
    Platform.find_binary("chromium-browser"),
    "/usr/bin/google-chrome"
  ].compact
end

.windows_pathsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 143

def windows_paths
  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

  paths.map! { |path| Platform.cygwin_path(path) } if Platform.cygwin?

  paths
end

.windows_registry_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 157

def windows_registry_path
  require "win32/registry"

  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

Instance Method Details

#launch(server_url) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
37
38
39
40
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 34

def launch(server_url)
  create_extension
  create_profile
  launch_chrome server_url

  pid
end

#quitObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 42

def quit
  @process.stop
end