Class: Selenium::Starter

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

Constant Summary collapse

SELENIUM_SERVER_VERSION =
"2.32.0"
USAGE =
<<-TEXT
Usage:
  selenium help    - this help
  selenium install - installs selenium
  selenium         - runs the selenium server
TEXT

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStarter

Returns a new instance of Starter.



17
18
19
# File 'lib/selenium/starter.rb', line 17

def initialize
  @wrapper = JarWrapper::Runner.new
end

Instance Attribute Details

#wrapperObject (readonly)

Returns the value of attribute wrapper.



15
16
17
# File 'lib/selenium/starter.rb', line 15

def wrapper
  @wrapper
end

Instance Method Details

#run(params) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/selenium/starter.rb', line 21

def run params
  install_dir = ENV['HOME'] + "/.selenium/assets"

  source   = "http://selenium.googlecode.com/files/selenium-server-#{SELENIUM_SERVER_VERSION}.zip"
  target   = install_dir + "/selenium-server-#{SELENIUM_SERVER_VERSION}.zip"
  jar_file = install_dir + "/selenium-#{SELENIUM_SERVER_VERSION}/selenium-server-standalone-#{SELENIUM_SERVER_VERSION}.jar"

  param = params.length == 0 ? "" : params.first

  case param
    when /(-v)|(--version)/ then
      puts "Version: #{Selenium::VERSION}"
    when 'install' then
      wrapper.install source, target
      puts ""
    when 'help' then
      puts USAGE and return
    else
      wrapper.jar_file = jar_file
      wrapper.java_opts = []
      wrapper.run params.nil? ? [] : params
  end
end