Class: Selenium::RemoteControl::RemoteControl

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/remote_control/remote_control.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, timeout_in_seconds = 2 * 60) ⇒ RemoteControl

Returns a new instance of RemoteControl.



8
9
10
11
12
# File 'lib/selenium/remote_control/remote_control.rb', line 8

def initialize(host, port, timeout_in_seconds = 2 * 60)
  @host, @port, @timeout_in_seconds = host, port, timeout_in_seconds
  @additional_args = []
  @shell = Nautilus::Shell.new
end

Instance Attribute Details

#additional_argsObject

Returns the value of attribute additional_args.



6
7
8
# File 'lib/selenium/remote_control/remote_control.rb', line 6

def additional_args
  @additional_args
end

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/selenium/remote_control/remote_control.rb', line 5

def host
  @host
end

#jar_fileObject

Returns the value of attribute jar_file.



6
7
8
# File 'lib/selenium/remote_control/remote_control.rb', line 6

def jar_file
  @jar_file
end

#log_toObject

Returns the value of attribute log_to.



6
7
8
# File 'lib/selenium/remote_control/remote_control.rb', line 6

def log_to
  @log_to
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/selenium/remote_control/remote_control.rb', line 5

def port
  @port
end

#timeout_in_secondsObject (readonly)

Returns the value of attribute timeout_in_seconds.



5
6
7
# File 'lib/selenium/remote_control/remote_control.rb', line 5

def timeout_in_seconds
  @timeout_in_seconds
end

Instance Method Details

#start(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/selenium/remote_control/remote_control.rb', line 14

def start(options = {})
  command = "java -jar \"#{jar_file}\""
  command << " -port #{@port}"
  command << " -timeout #{@timeout_in_seconds}"
  command << " #{additional_args.join(' ')}" unless additional_args.empty?
  command << " > #{log_to}" if log_to
  
  @shell.run command, {:background => options[:background]}
end

#stopObject



24
25
26
# File 'lib/selenium/remote_control/remote_control.rb', line 24

def stop
  Net::HTTP.get(@host, '/selenium-server/driver/?cmd=shutDown', @port)
end