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

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/firefox/binary.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.

Constant Summary collapse

NO_FOCUS_LIBRARY_NAME =

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

"x_ignore_nofocus.so"
NO_FOCUS_LIBRARIES =

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

[
  ["#{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 =

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

90
QUIT_TIMEOUT =

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

5

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.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.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/selenium/webdriver/firefox/binary.rb', line 135

def path
  @path ||= case Platform.os
            when :macosx
              macosx_path
            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

  @path = Platform.cygwin_path(@path) if Platform.cygwin?

  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

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
# File 'lib/selenium/webdriver/firefox/binary.rb', line 126

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

.reset_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.



131
132
133
# File 'lib/selenium/webdriver/firefox/binary.rb', line 131

def reset_path!
  @path = nil
end

.versionObject

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.



156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/selenium/webdriver/firefox/binary.rb', line 156

def version
  @version = case Platform.os
               when :macosx
                 `#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
               when :windows
                 `\"#{path}\" -v | more`.strip[/[^\s]*$/][/^\d+/].to_i
               when :linux
                 `#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
               else
                 0
               end
end

Instance Method Details

#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.



57
58
59
60
61
62
63
# File 'lib/selenium/webdriver/firefox/binary.rb', line 57

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

#start_with(profile, profile_path, *args) ⇒ 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.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/selenium/webdriver/firefox/binary.rb', line 36

def start_with(profile, profile_path, *args)
  if Platform.cygwin?
    profile_path = Platform.cygwin_path(profile_path, :windows => true)
  elsif Platform.windows?
    profile_path = profile_path.gsub("/", "\\")
  end

  ENV['XRE_CONSOLE_LOG']           = profile.log_file if profile.log_file
  ENV['XRE_PROFILE_PATH']          = profile_path
  ENV['MOZ_NO_REMOTE']             = '1' # able to launch multiple instances
  ENV['MOZ_CRASHREPORTER_DISABLE'] = '1' # disable breakpad
  ENV['NO_EM_RESTART']             = '1' # prevent the binary from detaching from the console

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

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

#waitObject

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.



65
66
67
68
69
70
71
72
73
74
# File 'lib/selenium/webdriver/firefox/binary.rb', line 65

def wait
  return unless @process

  begin
    @process.poll_for_exit(WAIT_TIMEOUT)
  rescue ChildProcess::TimeoutError => e
    @process.stop
    raise e
  end
end