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 = {})
  @default_profile = opts[:default_profile]
  @secure_ssl = !!opts[:secure_ssl]
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

.binary_path=(path) ⇒ Object



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

def self.binary_path=(path)
  Platform.assert_executable(path)
  @binary_path = path
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



49
50
51
52
53
54
55
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 49

def launch(server_url)
  create_extension
  create_profile
  launch_chrome server_url

  pid
end

#quitObject



57
58
59
# File 'lib/selenium/webdriver/chrome/launcher.rb', line 57

def quit
  @process.stop
end