Class: Selenium::WebDriver::Firefox::Binary
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Firefox::Binary
- 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}"], ]
Class Attribute Summary collapse
Instance Method Summary collapse
- #cope_with_mac_strangeness(args) ⇒ Object
- #create_base_profile(name) ⇒ Object
- #execute(*extra_args) ⇒ Object
- #kill ⇒ Object
- #pid ⇒ Object
- #quit ⇒ Object
- #start_with(profile, *args) ⇒ Object
- #wait ⇒ Object
Class Attribute Details
.path ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 99 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) 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 |
Instance Method Details
#cope_with_mac_strangeness(args) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 44 def cope_with_mac_strangeness(args) sleep 0.3 if @process.ugly_death? # process crashed, trying a restart. sleeping 5 seconds shorter than the java driver sleep 5 execute(*args) end # ensure we're ok sleep 0.3 if @process.ugly_death? raise Error::WebDriverError, "unable to start Firefox cleanly, args: #{args.inspect}" end end |
#create_base_profile(name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 14 def create_base_profile(name) execute("-CreateProfile", name) status = nil Timeout.timeout(15, Error::TimeOutError) do _, status = wait end if status && status.to_i != 0 raise Error::WebDriverError, "could not create base profile: (exit status: #{status})" end end |
#execute(*extra_args) ⇒ Object
39 40 41 42 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 39 def execute(*extra_args) args = [self.class.path, "-no-remote", "--verbose"] + extra_args @process = ChildProcess.new(*args).start end |
#kill ⇒ Object
64 65 66 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 64 def kill @process.kill if @process end |
#pid ⇒ Object
72 73 74 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 72 def pid @process.pid if @process end |
#quit ⇒ Object
60 61 62 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 60 def quit @process.ensure_death if @process end |
#start_with(profile, *args) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 27 def start_with(profile, *args) ENV['XRE_PROFILE_PATH'] = profile.absolute_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 end execute(*args) cope_with_mac_strangeness(args) if Platform.mac? end |
#wait ⇒ Object
68 69 70 |
# File 'lib/selenium/webdriver/firefox/binary.rb', line 68 def wait @process.wait if @process end |