selenium 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -7,4 +7,4 @@
7
7
 
8
8
  == Version 0.0.3
9
9
 
10
- * Addign suppoert for windows.
10
+ * Adding support for windows.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/bin/selenium CHANGED
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
4
-
5
3
  require 'rubygems' unless RUBY_VERSION =~ /1.9.*/
6
- require 'selenium'
4
+ require 'jar_wrapper'
7
5
 
8
6
  class SeleniumStarter
7
+ SELENIUM_VERSION = "2.5.0"
9
8
 
10
9
  USAGE= <<-TEXT
11
10
  Usage:
@@ -15,27 +14,29 @@ class SeleniumStarter
15
14
  TEXT
16
15
 
17
16
  def initialize
18
- @selenium = Selenium.new
17
+ @wrapper = JarWrapper.new
19
18
  end
20
19
 
21
20
  def run
22
21
  install_dir = ENV['HOME'] + "/.selenium/assets"
23
- verion = "2.5.0"
24
- source = "http://selenium.googlecode.com/files/selenium-server-#{verion}.zip"
25
- target = install_dir + "/selenium-server-#{verion}.zip"
26
- jar_file = install_dir + "/selenium-#{verion}/selenium-server-standalone-#{verion}.jar"
27
22
 
28
- case ARGV.shift
23
+ source = "http://selenium.googlecode.com/files/selenium-server-#{SELENIUM_VERSION}.zip"
24
+ target = install_dir + "/selenium-server-#{SELENIUM_VERSION}.zip"
25
+ jar_file = install_dir + "/selenium-#{SELENIUM_VERSION}/selenium-server-standalone-#{SELENIUM_VERSION}.jar"
26
+
27
+ param = ARGV.length == 0 ? "" : ARGV.first
28
+
29
+ case param
29
30
  when /(-v)|(--version)/ then
30
31
  puts "Version: #{File.open(File::dirname(__FILE__) + "/../VERSION").readlines().first}"
31
32
  when 'install' then
32
- @selenium.install source, target
33
+ @wrapper.install source, target
33
34
  when 'help' then
34
35
  puts USAGE and return
35
36
  else
36
- @selenium.run jar_file
37
+ @wrapper.jar_file = jar_file1
38
+ @wrapper.run jar_file ARGV
37
39
  end
38
40
  end
39
41
  end
40
42
 
41
- SeleniumStarter.new.run
data/selenium.gemspec CHANGED
@@ -5,15 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{selenium}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Alexander Shvets"]
12
- s.date = %q{2011-08-30}
13
- s.default_executable = %q{selenium}
11
+ s.authors = [%q{Alexander Shvets}]
12
+ s.date = %q{2011-09-23}
14
13
  s.description = %q{Gem wrapper for selenium server.}
15
14
  s.email = %q{alexander.shvets@gmail.com}
16
- s.executables = ["selenium"]
15
+ s.executables = [%q{selenium}]
17
16
  s.extra_rdoc_files = [
18
17
  "README"
19
18
  ]
@@ -22,13 +21,8 @@ Gem::Specification.new do |s|
22
21
  "README",
23
22
  "Rakefile",
24
23
  "VERSION",
25
- "bin/Gemfile",
26
24
  "bin/selenium",
27
25
  "bin/selenium.bat",
28
- "lib/selenium.rb",
29
- "lib/selenium/jvm_options_probe.rb",
30
- "lib/selenium/runner.rb",
31
- "lib/selenium/selenium.rb",
32
26
  "selenium.gemspec"
33
27
  ]
34
28
  s.homepage = %q{http://github.com/shvets/selenium}
@@ -44,9 +38,9 @@ Gem::Specification.new do |s|
44
38
 
45
39
  -------------------------------------------------------------------------------
46
40
  }
47
- s.require_paths = ["lib"]
48
- s.requirements = ["none"]
49
- s.rubygems_version = %q{1.6.2}
41
+ s.require_paths = [%q{lib}]
42
+ s.requirements = [%q{none}]
43
+ s.rubygems_version = %q{1.8.6}
50
44
  s.summary = %q{Gem wrapper for selenium server (Summary).}
51
45
 
52
46
  if s.respond_to? :specification_version then
@@ -54,20 +48,20 @@ Gem::Specification.new do |s|
54
48
 
55
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
50
  s.add_runtime_dependency(%q<jeweler>, [">= 0"])
57
- s.add_runtime_dependency(%q<zip>, [">= 0"])
51
+ s.add_runtime_dependency(%q<jar_wrapper>, [">= 0"])
58
52
  s.add_runtime_dependency(%q<jeweler>, [">= 0"])
59
- s.add_runtime_dependency(%q<zip>, [">= 0"])
53
+ s.add_runtime_dependency(%q<jar_wrapper>, [">= 0"])
60
54
  else
61
55
  s.add_dependency(%q<jeweler>, [">= 0"])
62
- s.add_dependency(%q<zip>, [">= 0"])
56
+ s.add_dependency(%q<jar_wrapper>, [">= 0"])
63
57
  s.add_dependency(%q<jeweler>, [">= 0"])
64
- s.add_dependency(%q<zip>, [">= 0"])
58
+ s.add_dependency(%q<jar_wrapper>, [">= 0"])
65
59
  end
66
60
  else
67
61
  s.add_dependency(%q<jeweler>, [">= 0"])
68
- s.add_dependency(%q<zip>, [">= 0"])
62
+ s.add_dependency(%q<jar_wrapper>, [">= 0"])
69
63
  s.add_dependency(%q<jeweler>, [">= 0"])
70
- s.add_dependency(%q<zip>, [">= 0"])
64
+ s.add_dependency(%q<jar_wrapper>, [">= 0"])
71
65
  end
72
66
  end
73
67
 
metadata CHANGED
@@ -1,145 +1,101 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: selenium
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Alexander Shvets
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-30 00:00:00 -04:00
19
- default_executable: selenium
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :runtime
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
12
+ date: 2011-09-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
33
15
  name: jeweler
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- prerelease: false
37
- type: :runtime
38
- requirement: &id002 !ruby/object:Gem::Requirement
16
+ requirement: &2153031700 !ruby/object:Gem::Requirement
39
17
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
47
- name: zip
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- prerelease: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
51
22
  type: :runtime
52
- requirement: &id003 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: *2153031700
25
+ - !ruby/object:Gem::Dependency
26
+ name: jar_wrapper
27
+ requirement: &2153030940 !ruby/object:Gem::Requirement
53
28
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
61
- name: jeweler
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
64
34
  prerelease: false
35
+ version_requirements: *2153030940
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &2153030100 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
65
44
  type: :runtime
66
- requirement: &id004 !ruby/object:Gem::Requirement
45
+ prerelease: false
46
+ version_requirements: *2153030100
47
+ - !ruby/object:Gem::Dependency
48
+ name: jar_wrapper
49
+ requirement: &2153029520 !ruby/object:Gem::Requirement
67
50
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
75
- name: zip
76
- version_requirements: *id004
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *2153029520
77
58
  description: Gem wrapper for selenium server.
78
59
  email: alexander.shvets@gmail.com
79
- executables:
60
+ executables:
80
61
  - selenium
81
62
  extensions: []
82
-
83
- extra_rdoc_files:
63
+ extra_rdoc_files:
84
64
  - README
85
- files:
65
+ files:
86
66
  - CHANGES
87
67
  - README
88
68
  - Rakefile
89
69
  - VERSION
90
- - bin/Gemfile
91
70
  - bin/selenium
92
71
  - bin/selenium.bat
93
- - lib/selenium.rb
94
- - lib/selenium/jvm_options_probe.rb
95
- - lib/selenium/runner.rb
96
- - lib/selenium/selenium.rb
97
72
  - selenium.gemspec
98
- has_rdoc: true
99
73
  homepage: http://github.com/shvets/selenium
100
74
  licenses: []
101
-
102
- post_install_message: |
103
-
104
- -------------------------------------------------------------------------------
105
-
106
- Please now run:
107
-
108
- $ selenium install
109
-
110
- NB. This will download jars that this gem needs to run from the internet.
111
- It will put them into ~/.selenium/assets.
112
-
113
- -------------------------------------------------------------------------------
114
-
75
+ post_install_message: ! "\n -------------------------------------------------------------------------------\n\n
76
+ \ Please now run:\n\n $ selenium install\n\n NB. This will download
77
+ jars that this gem needs to run from the internet.\n It will put them into
78
+ ~/.selenium/assets.\n\n -------------------------------------------------------------------------------\n"
115
79
  rdoc_options: []
116
-
117
- require_paths:
80
+ require_paths:
118
81
  - lib
119
- required_ruby_version: !ruby/object:Gem::Requirement
82
+ required_ruby_version: !ruby/object:Gem::Requirement
120
83
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 3
125
- segments:
126
- - 0
127
- version: "0"
128
- required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
89
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- hash: 3
134
- segments:
135
- - 0
136
- version: "0"
137
- requirements:
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements:
138
95
  - none
139
96
  rubyforge_project:
140
- rubygems_version: 1.6.2
97
+ rubygems_version: 1.8.6
141
98
  signing_key:
142
99
  specification_version: 3
143
100
  summary: Gem wrapper for selenium server (Summary).
144
101
  test_files: []
145
-
data/bin/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- group :development do
4
- gem "jeweler"
5
- end
data/lib/selenium.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'rubygems' unless RUBY_VERSION =~ /1.9.*/
2
-
3
- $:.unshift(File.dirname(__FILE__)) unless
4
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
-
6
- require 'fileutils'
7
- require 'net/http'
8
-
9
- require 'selenium/selenium'
10
- require 'selenium/runner'
11
- require 'selenium/jvm_options_probe'
12
-
13
- require 'rbconfig'
14
- WINDOZE = Config::CONFIG['host_os'] =~ /mswin|mingw|windows/
15
-
16
- WINDOZE ? (require "zip/zipfilesystem") : (require 'zip/zip')
@@ -1,35 +0,0 @@
1
- require 'rbconfig'
2
-
3
- require 'open3' unless Config::CONFIG['host_os'] =~ /mswin|mingw|windows/
4
-
5
- class JvmOptionsProbe
6
-
7
- def initialize
8
- @d32 = @d64 = @client = false
9
-
10
- if WINDOZE
11
- @help = `java -h`
12
- @d32 = (@help == `java -d32`) ? true : false
13
- @d64 = (@help == `java -d64`) ? true : false
14
- @client = (@help == `java -client`) ? true : false
15
- else
16
- @help = Open3.popen3("java -h")[2].readlines
17
- @d32 = (@help == Open3.popen3("java -d32")[2].readlines) ? true : false
18
- @d64 = (@help == Open3.popen3("java -d64")[2].readlines) ? true : false
19
- @client = (@help == Open3.popen3("java -client")[2].readlines) ? true : false
20
- end
21
- end
22
-
23
- def can_use_d32?
24
- @d32
25
- end
26
-
27
- def can_use_d64?
28
- @d64
29
- end
30
-
31
- def can_use_client?
32
- @client
33
- end
34
- end
35
-
@@ -1,117 +0,0 @@
1
-
2
- class Runner
3
- def run jar_file
4
- @jar_file = jar_file
5
-
6
- # forking = ARGV.include?("--fork") and ARGV.first != "install"
7
- # no_runner = ARGV.include?("--no-sub-jruby")
8
- # jruby = Config::CONFIG["RUBY_INSTALL_NAME"] == "jruby"
9
- # osx = !(RUBY_PLATFORM =~/(windows|linux)/)
10
- # begin
11
- # if forking and not jruby
12
- # # jRuby doesn't support fork() because of the runtime stuff...
13
- # forking = false
14
- # puts 'Forking failed, attempting to start anyway...' if (pid = fork) == -1
15
- # exit unless pid.nil? # kill the parent process
16
- #
17
- # if pid.nil?
18
- # # reopen the standard pipes to nothingness
19
- # # STDIN.reopen Redcar.null_device
20
- # # STDOUT.reopen Redcar.null_device, 'a'
21
- # STDERR.reopen STDOUT
22
- # end
23
- # elsif forking and SPOON_AVAILABLE and ::Spoon.supported?
24
- # # so we need to try something different...
25
- #
26
- # forking = false
27
- # construct_command do |command|
28
- # command.push('--silent')
29
- # ::Spoon.spawnp(*command)
30
- # end
31
- # exit 0
32
- # elsif forking
33
- # raise NotImplementedError, "Something weird has happened. Please contact us."
34
- # end
35
- # rescue NotImplementedError
36
- # puts $!.class.name + ": " + $!.message
37
- # puts "Forking isn't supported on this system. Sorry."
38
- # puts "Starting normally..."
39
- # end
40
- #
41
- # return if no_runner
42
- # return if jruby and not osx
43
-
44
- construct_command do |command|
45
- exec(command.join(" "))
46
- end
47
-
48
- end
49
-
50
- # Trade in this Ruby instance for a JRuby instance, loading in a
51
- # starter script and passing it some arguments.
52
- # If --jruby is passed, use the installed version of jruby, instead of
53
- # our vendored jarred one (useful for gems).
54
- def construct_command(args="")
55
- bin = File.expand_path(File.join(File.dirname(__FILE__), %w{.. .. bin selenium}))
56
- ENV['RUBYOPT'] = nil # disable other native args
57
-
58
- # Windows XP updates
59
-
60
- # if RUBY_PLATFORM =~ /window/
61
- # bin = "\"#{bin}\""
62
- # jruby_complete = "\"#{jruby_complete}\""
63
- # end
64
-
65
- # unfortuanately, ruby doesn't support [a, *b, c]
66
- command = ["java"]
67
- command.push(*java_args)
68
- command.push("-Xmx500m", "-Xss1024k")
69
- command.push("-jar", @jar_file)
70
- #command.push("-Djruby.memory.max=500m", "-Djruby.stack.max=1024k", "-cp", jruby_complete, "org.jruby.Main")
71
-
72
- command.push "--debug" if debug_mode?
73
- # command.push(bin)
74
- # command.push(*cleaned_args)
75
- # command.push("--no-sub-jruby", "--ignore-stdin")
76
- command.push(*args)
77
-
78
- puts command.join(' ')
79
- yield command
80
- end
81
-
82
- # def cleaned_args
83
- # # We should never pass --fork to a subprocess
84
- # result = ARGV.find_all {|arg| arg != '--fork'}.map do |arg|
85
- # if arg =~ /--(.+)=(.+)/
86
- # "--" + $1 + "=\"" + $2 + "\""
87
- # else
88
- # arg
89
- # end
90
- # end
91
- # result.delete("install")
92
- # result
93
- # end
94
-
95
- def debug_mode?
96
- ARGV.include?("--debug")
97
- end
98
-
99
- def java_args
100
- str = []
101
- if Config::CONFIG["host_os"] =~ /darwin/
102
- str.push "-XstartOnFirstThread"
103
- end
104
-
105
- # if ARGV.include?("--load-timings")
106
- # str.push "-Djruby.debug.loadService.timing=true"
107
- # end
108
-
109
- jvm_options_probe = JvmOptionsProbe.new
110
-
111
- str.push "-d32" if jvm_options_probe.can_use_d32?
112
- str.push "-client" if jvm_options_probe.can_use_client?
113
-
114
- str
115
- end
116
- end
117
-
@@ -1,68 +0,0 @@
1
- require 'open-uri'
2
-
3
- class Selenium
4
- def download_file_to(uri, destination_file)
5
- print " downloading #{uri}... "; $stdout.flush
6
-
7
- temp = destination_file + ".part"
8
- FileUtils.mkdir_p(File.dirname(destination_file))
9
-
10
- File.open(temp, "wb") do |out_file|
11
- open(uri) do |in_file|
12
- done = false
13
-
14
- while(!done) do
15
- buffer = in_file.read(1024*1000)
16
- out_file.write(buffer)
17
-
18
- if buffer.nil? || buffer.size == 0
19
- done = true
20
- else
21
- print("#"); $stdout.flush
22
- end
23
- end
24
- end
25
- end
26
-
27
- if File.open(temp).read(200) =~ /Access Denied/
28
- puts "\n\n*** Error downloading #{uri}, got Access Denied from S3."
29
- FileUtils.rm_rf(temp)
30
- exit
31
- end
32
-
33
- FileUtils.cp(temp, destination_file)
34
- FileUtils.rm_rf(temp)
35
- puts "\ndone!"
36
- end
37
-
38
- # unzip a .zip file into the directory it is located
39
- def unzip_file(path)
40
- print "unzipping #{path}..."; $stdout.flush
41
- source = File.expand_path(path)
42
- Dir.chdir(File.dirname(source)) do
43
- Zip::ZipFile.open(source) do |zipfile|
44
- zipfile.entries.each do |entry|
45
- FileUtils.mkdir_p(File.dirname(entry.name))
46
- begin
47
- entry.extract
48
- rescue Zip::ZipDestinationFileExistsError
49
- end
50
- end
51
- end
52
- end
53
- end
54
-
55
- def install source, destination
56
- download_file_to(source, destination)
57
-
58
- unzip_file(destination) if destination =~ /\.zip$/
59
- end
60
-
61
- def run jar_file
62
- runner = Runner.new
63
-
64
- runner.run jar_file
65
- end
66
- end
67
-
68
-