Class: Selenium::WebDriver::Firefox::Binary

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/firefox/binary.rb

Constant Summary collapse

NO_FOCUS_LIBRARY_NAME =
"x_ignore_nofocus.so"
NO_FOCUS_LIBRARIES =
[
  ["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/amd64/#{NO_FOCUS_LIBRARY_NAME}", "amd64/#{NO_FOCUS_LIBRARY_NAME}"],
  ["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/x86/#{NO_FOCUS_LIBRARY_NAME}", "x86/#{NO_FOCUS_LIBRARY_NAME}"],
]
WAIT_TIMEOUT =
90

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.pathObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/selenium/webdriver/firefox/binary.rb', line 97

def path
  @path ||= case Platform.os
            when :macosx
              "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
            when :windows
              windows_path
            when :linux, :unix
              Platform.find_binary("firefox3", "firefox2", "firefox") || "/usr/bin/firefox"
            else
              raise Error::WebDriverError, "unknown platform: #{Platform.os}"
            end

  unless File.file?(@path.to_s)
    raise Error::WebDriverError, "Could not find Firefox binary (os=#{Platform.os}). Make sure Firefox is installed or set the path manually with #{self}.path="
  end

  @path
end

.path=(path) ⇒ Object



92
93
94
95
# File 'lib/selenium/webdriver/firefox/binary.rb', line 92

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

Instance Method Details

#quitObject



32
33
34
35
36
37
38
# File 'lib/selenium/webdriver/firefox/binary.rb', line 32

def quit
  return unless @process
  @process.poll_for_exit 5
rescue ChildProcess::TimeoutError
  # ok, force quit
  @process.stop 5
end

#start_with(profile, profile_path, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/selenium/webdriver/firefox/binary.rb', line 16

def start_with(profile, profile_path, *args)
  profile_path = profile_path.gsub("/", "\\") if Platform.win?

  ENV['XRE_PROFILE_PATH'] = profile_path
  ENV['MOZ_NO_REMOTE'] = '1' # able to launch multiple instances

  if Platform.linux? && (profile.native_events? || profile.load_no_focus_lib?)
    modify_link_library_path profile_path
  end

  ENV['XRE_CONSOLE_LOG'] = profile.log_file if profile.log_file

  execute(*args)
  cope_with_mac_strangeness(args) if Platform.mac?
end

#waitObject



40
41
42
# File 'lib/selenium/webdriver/firefox/binary.rb', line 40

def wait
  @process.poll_for_exit(WAIT_TIMEOUT) if @process
end