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, options = {}) ⇒ RemoteControl

Returns a new instance of RemoteControl.


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

def initialize(host, port, options={})
  @host, @port = host, port
  @timeout_in_seconds = options[:timeout] || (2 * 60)
  @shutdown_command = options[:shutdown_command] || "shutDownSeleniumServer"
  @firefox_profile = options[:firefox_profile]
  @additional_args = options[: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

#firefox_profileObject (readonly)

Returns the value of attribute firefox_profile


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

def firefox_profile
  @firefox_profile
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

#shutdown_commandObject (readonly)

Returns the value of attribute shutdown_command


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

def shutdown_command
  @shutdown_command
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


17
18
19
20
21
22
23
24
25
26
# File 'lib/selenium/remote_control/remote_control.rb', line 17

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

#stopObject


28
29
30
# File 'lib/selenium/remote_control/remote_control.rb', line 28

def stop
  Net::HTTP.get(@host, "/selenium-server/driver/?cmd=#{shutdown_command}", @port)
end