Class: Selenium::WebDriver::Firefox::Launcher Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Firefox::Launcher
- Defined in:
- lib/selenium/webdriver/firefox/launcher.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
- SOCKET_LOCK_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.
45
- STABLE_CONNECTION_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.
60
Instance Method Summary collapse
- #assert_profile ⇒ Object private
- #connect_until_stable ⇒ Object private
- #create_profile ⇒ Object private
- #fetch_profile ⇒ Object private
- #find_free_port ⇒ Object private
-
#initialize(binary, port, profile = nil) ⇒ Launcher
constructor
private
A new instance of Launcher.
- #launch ⇒ Object private
- #quit ⇒ Object private
- #socket_lock ⇒ Object private
- #start ⇒ Object private
- #url ⇒ Object private
Constructor Details
#initialize(binary, port, profile = nil) ⇒ Launcher
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.
Returns a new instance of Launcher.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 30 def initialize(binary, port, profile = nil) @binary = binary @port = Integer(port) raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1 if profile.kind_of? Profile @profile = profile else @profile_name = profile @profile = nil end @host = "127.0.0.1" end |
Instance Method Details
#assert_profile ⇒ 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.
106 107 108 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 106 def assert_profile raise Error::WebDriverError, "must create_profile first" unless @profile && @profile_dir end |
#connect_until_stable ⇒ 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.
85 86 87 88 89 90 91 92 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 85 def connect_until_stable poller = SocketPoller.new(@host, @port, STABLE_CONNECTION_TIMEOUT) unless poller.connected? @binary.quit raise Error::WebDriverError, "unable to obtain stable firefox connection in #{STABLE_CONNECTION_TIMEOUT} seconds (#{@host}:#{@port})" end end |
#create_profile ⇒ 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.
70 71 72 73 74 75 76 77 78 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 70 def create_profile fetch_profile unless @profile @profile.add_webdriver_extension @profile.port = @port @profile_dir = @profile.layout_on_disk FileReaper << @profile_dir end |
#fetch_profile ⇒ 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.
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 94 def fetch_profile if @profile_name @profile = Profile.from_name @profile_name unless @profile raise Error::WebDriverError, "unable to find profile named: #{@profile_name.inspect}" end else @profile = Profile.new end end |
#find_free_port ⇒ 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.
66 67 68 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 66 def find_free_port @port = PortProber.above @port end |
#launch ⇒ 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.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 50 def launch socket_lock.locked do find_free_port create_profile start connect_until_stable end self end |
#quit ⇒ 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.
61 62 63 64 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 61 def quit @binary.quit FileReaper.reap(@profile_dir) if @profile_dir end |
#socket_lock ⇒ 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.
110 111 112 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 110 def socket_lock @socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT) end |
#start ⇒ 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.
80 81 82 83 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 80 def start assert_profile @binary.start_with @profile, @profile_dir, "-foreground" end |
#url ⇒ 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.
46 47 48 |
# File 'lib/selenium/webdriver/firefox/launcher.rb', line 46 def url "http://#{@host}:#{@port}/hub" end |