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

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

Direct Known Subclasses

UnixLauncher, WindowsLauncher

Defined Under Namespace

Classes: MacOSXLauncher, UnixLauncher, WindowsLauncher

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Launcher

Returns a new instance of Launcher.



26
27
28
29
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 26

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

Instance Attribute Details

#pidObject (readonly)

Returns the value of attribute pid.



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

def pid
  @pid
end

Class Method Details

.binary_pathObject



31
32
33
34
35
36
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 31

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

.launcher(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 11

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

Instance Method Details

#launch(server_url) ⇒ Object



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

def launch(server_url)
  create_extension
  create_profile
  launch_chrome server_url

  pid
end

#quitObject



46
47
48
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 46

def quit
  @process.ensure_death
end