ph7 / selenium-client

Official Ruby client API for Selenium Remote Control (bare bone client driver)

This URL has Read+Write access

ph7 (author)
Mon Feb 02 20:41:28 -0800 2009
commit  d1cde31cb7ae677a116869d2bb32ddf835375b77
tree    0a05d9fd61e8ccebc1f909f13bb338044f6c107c
parent  d351fc94dc35d6d244d27036d1d812dec78e00a8
selenium-client / Rakefile
100644 189 lines (162 sloc) 6.728 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Rakefile for Selenium Ruby Client -*- ruby -*-
 
$:.unshift 'lib'
 
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
 
require 'rubygems'
gem "rspec", "1.1.12"
require 'spec/rake/spectask'
require 'selenium/rake/tasks'
 
CLEAN.include("COMMENTS")
CLEAN.include('lib/selenium/client/generated_driver.rb', '**/*.log', "target", "pkg")
 
if ENV["SELENIUM_RC_JAR"]
# User override
SELENIUM_RC_JAR = ENV["SELENIUM_RC_JAR"]
elsif not Dir[File.dirname(__FILE__) + "/../../selenium-server/target/selenium-server-*-standalone.jar"].empty?
# We are part of the global Selenium RC Build
SELENIUM_RC_JAR = Dir[File.dirname(__FILE__) + "/../../selenium-server/target/selenium-server-*-standalone.jar"].first
else
# Bundled version
SELENIUM_RC_JAR = Dir[File.dirname(__FILE__) + "/vendor/selenium-remote-control/selenium-server-*-standalone.jar"].first
end
 
raise "Invalid Selenium RC jar : '#{SELENIUM_RC_JAR}" unless File.exists?(SELENIUM_RC_JAR)
  
task :default => :"test:unit"
 
desc "Start a Selenium remote control, run all integration tests and stop the remote control"
task :'ci:integration' => [ :clean, :'test:unit' ] do
  Rake::Task[:"selenium:rc:stop"].execute [] rescue nil
  begin
    Rake::Task[:"selenium:rc:start"].execute []
    Rake::Task[:"test:integration"].execute []
  ensure
    Rake::Task[:"selenium:rc:stop"].execute []
  end
end
 
file "target/iedoc.xml" do
sh "unzip -uj '#{SELENIUM_RC_JAR}' core/iedoc.xml -d target"
end
 
desc "Generate driver from iedoc.xml"
file "lib/selenium/client/generated_driver.rb" => [ "target/iedoc.xml" ] do
  sh "ant generate-sources"
end
 
desc "Run unit tests"
Rake::TestTask.new(:'test:unit') do |t|
  t.test_files = FileList['test/unit/**/*_test.rb']
  t.warning = true
end
task :"test:unit" => "lib/selenium/client/generated_driver.rb"
 
Selenium::Rake::RemoteControlStartTask.new do |rc|
  rc.port = 4444
  rc.timeout_in_seconds = 3 * 60
  rc.background = true
  rc.wait_until_up_and_running = true
  rc.jar_file = SELENIUM_RC_JAR
  rc.additional_args << "-singleWindow"
end
 
Selenium::Rake::RemoteControlStopTask.new do |rc|
  rc.host = "localhost"
  rc.port = 4444
  rc.timeout_in_seconds = 3 * 60
end
 
desc "Run all integration tests"
Spec::Rake::SpecTask.new("test:integration") do |t|
    t.spec_files = FileList['test/integration/**/*_spec.rb'] - FileList['test/integration/**/dummy_project/*_spec.rb']
    t.spec_opts << '--color'
    t.spec_opts << "--require 'lib/selenium/rspec/reporting/selenium_test_report_formatter'"
    t.spec_opts << "--format=Selenium::RSpec::SeleniumTestReportFormatter:./target/integration_tests_report.html"
    t.spec_opts << "--format=progress"
end
task :"test:integration" => ["lib/selenium/client/generated_driver.rb", :'test:integration:headless']
 
begin
  gem "deep_test", ">=1.2.1"
  require "deep_test/rake_tasks"
 
  desc "Run all integration tests in parallel"
  Spec::Rake::SpecTask.new("test:integration:parallel") do |t|
      t.spec_files = FileList['test/integration/**/*.rb']
      t.spec_opts << '--color'
      t.spec_opts << "--require 'lib/selenium/rspec/reporting/selenium_test_report_formatter'"
      t.spec_opts << "--format=Selenium::RSpec::SeleniumTestReportFormatter:./target/integration_tests_report.html"
      t.spec_opts << "--format=progress"
      t.deep_test :number_of_workers => 5,
                  :timeout_in_seconds => 180
  end
rescue Exception
  puts "Could not find DeepTest, disable parallel run"
end
 
desc "Run headless integration tests"
Rake::TestTask.new(:'test:integration:headless') do |t|
  t.test_files = FileList['test/integration/headless/**/*.rb']
  t.warning = true
end
 
desc "Run API integration tests"
Spec::Rake::SpecTask.new("test:integration:api") do |t|
    t.spec_files = FileList['test/integration/api/**/*_spec.rb']
    t.spec_opts << '--color'
    t.spec_opts << "--require 'lib/selenium/rspec/reporting/selenium_test_report_formatter'"
    t.spec_opts << "--format=Selenium::RSpec::SeleniumTestReportFormatter:./target/api_integration_tests_report.html"
    t.spec_opts << "--format=progress"
end
 
desc "Run API integration tests"
Spec::Rake::SpecTask.new("test:integration:smoke") do |t|
    t.spec_files = FileList['test/integration/smoke/**/*backward*.rb']
    t.spec_opts << '--color'
    t.spec_opts << "--require 'lib/selenium/rspec/reporting/selenium_test_report_formatter'"
    t.spec_opts << "--format=Selenium::RSpec::SeleniumTestReportFormatter:./target/smoke_tests_report.html"
    t.spec_opts << "--format=progress"
end
 
desc "Run tests that are part of Selenium RC maven build (When Selenium Client is part of Selenium RC Workspace)."
task :'test:maven_build' do |t|
  Rake::Task[:"test:unit"].invoke
  if (ENV['HEADLESS_TEST_MODE'] || "").downcase == "true"
    puts "Headless test mode detected"
    Rake::Task[:"test:integration:headless"].invoke
  else
    Rake::Task[:"test:integration"].invoke
  end
end
 
desc "Run tests in parallel"
Spec::Rake::SpecTask.new("test:parallel") do |t|
    t.spec_files = FileList['test/integration/*_spec.rb']
    t.spec_opts << '--color'
    t.spec_opts << "--require 'lib/selenium/rspec/reporting/selenium_test_report_formatter'"
    t.spec_opts << "--format=Selenium::RSpec::SeleniumTestReportFormatter:./target/report.html"
    t.spec_opts << "--format=progress"
end
 
specification = Gem::Specification.new do |s|
  s.name = "selenium-client"
  s.summary = "Official Ruby Client for Selenium RC."
  s.version = "1.2.10"
  s.author = "OpenQA"
  s.email = 'selenium-client@rubyforge.org'
  s.homepage = "http://selenium-client.rubyforge.com"
  s.rubyforge_project = 'selenium-client'
  s.platform = Gem::Platform::RUBY
  s.files = FileList['lib/**/*.rb']
  s.require_path = "lib"
  s.extensions = []
  s.rdoc_options << '--title' << 'Selenium Client' << '--main' << 'README' << '--line-numbers'
  s.has_rdoc = true
  s.extra_rdoc_files = ['README.markdown']
s.test_file = "test/all_unit_tests.rb"
end
 
Rake::GemPackageTask.new(specification) do |package|
  package.need_zip = false
  package.need_tar = false
end
 
desc "Build the RubyGem"
task :gem
 
desc "Generate documentation"
Rake::RDocTask.new("rdoc") do |rdoc|
  rdoc.title = "Selenium Client"
  rdoc.main = "README"
  rdoc.rdoc_dir = "doc"
  rdoc.rdoc_files.include('README.markdown')
  rdoc.rdoc_files.include('lib/**/*.rb')
  rdoc.rdoc_files.include('doc/**/*.rdoc')
  rdoc.options << '--line-numbers' << '--inline-source'
end
 
desc "Publish RDoc on Rubyforge website"
task :'rdoc:publish' => :rdoc do
  sh "scp -r doc/* #{ENV['USER']}@rubyforge.org:/var/www/gforge-projects/selenium-client"
end