class Selenium::WebDriver::IE::Server

@api private

Constants

MISSING_TEXT
SOCKET_LOCK_TIMEOUT
STOP_TIMEOUT

Attributes

log_file[RW]
log_level[RW]

Public Class Methods

get(opts = {}) click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 33
def self.get(opts = {})
  binary = IE.driver_path || Platform.find_binary("IEDriverServer")

  if binary
    new binary, opts
  else
    raise Error::WebDriverError, MISSING_TEXT
  end
end
new(binary_path, opts = {}) click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 45
def initialize(binary_path, opts = {})
  Platform.assert_executable binary_path

  @binary_path = binary_path
  @process = nil

  opts = opts.dup

  @log_level      = opts.delete(:log_level)
  @log_file       = opts.delete(:log_file)
  @implementation = opts.delete(:implementation)

  unless opts.empty?
    raise ArgumentError, "invalid option#{'s' if opts.size != 1}: #{opts.inspect}"
  end
end

Public Instance Methods

port() click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 83
def port
  @port
end
running?() click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 91
def running?
  @process && @process.alive?
end
start(port, timeout) click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 62
def start(port, timeout)
  return @port if running?

  @port = port
  socket_lock.locked do
    find_free_port
    start_process
    connect_until_stable(timeout)
  end

  Platform.exit_hook { stop } # make sure we don't leave the server running

  @port
end
stop() click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 77
def stop
  if running?
    @process.stop STOP_TIMEOUT
  end
end
uri() click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 87
def uri
  "http://#{Platform.localhost}:#{port}"
end

Private Instance Methods

connect_until_stable(timeout) click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 117
def connect_until_stable(timeout)
  socket_poller = SocketPoller.new Platform.localhost, @port, timeout

  unless socket_poller.connected?
    raise Error::WebDriverError, "unable to connect to IE server within #{timeout} seconds"
  end
end
find_free_port() click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 107
def find_free_port
  @port = PortProber.above @port
end
server_args() click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 97
def server_args
  args = ["--port=#{@port}"]

  args << "--log-level=#{@log_level.to_s.upcase}" if @log_level
  args << "--log-file=#{@log_file}" if @log_file
  args << "--implementation=#{@implementation.to_s.upcase}" if @implementation

  args
end
socket_lock() click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 125
def socket_lock
  @socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
end
start_process() click to toggle source
# File lib/selenium/webdriver/ie/server.rb, line 111
def start_process
  @process = ChildProcess.new(@binary_path, *server_args)
  @process.io.inherit! if $DEBUG
  @process.start
end