saucelabs-adapter 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.markdown +150 -0
- data/Rakefile +108 -0
- data/VERSION +1 -0
- data/generators/saucelabs_adapter/saucelabs_adapter_generator.rb +49 -0
- data/generators/saucelabs_adapter/templates/jsunit.rake +62 -0
- data/generators/saucelabs_adapter/templates/jsunit_suite_example.rb +19 -0
- data/generators/saucelabs_adapter/templates/saucelabs_adapter.rake +53 -0
- data/generators/saucelabs_adapter/templates/selenium.yml +66 -0
- data/lib/saucelabs-adapter.rb +1 -0
- data/lib/saucelabs_adapter.rb +6 -0
- data/lib/saucelabs_adapter/jsunit_selenium_support.rb +121 -0
- data/lib/saucelabs_adapter/run_utils.rb +14 -0
- data/lib/saucelabs_adapter/sauce_tunnel.rb +122 -0
- data/lib/saucelabs_adapter/selenium_config.rb +152 -0
- data/lib/saucelabs_adapter/test_unit_adapter.rb +49 -0
- data/lib/saucerest-ruby/gateway.rb +35 -0
- data/lib/saucerest-ruby/saucerest.rb +56 -0
- data/spec/selenium_config_spec.rb +151 -0
- data/test/helper.rb +10 -0
- data/test/test_saucelabs-adapter.rb +10 -0
- metadata +124 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Kelly Felkins & Sam Pierson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
Saucelabs-Adapter
|
2
|
+
=================
|
3
|
+
|
4
|
+
Saucelabs-adapter provides the glue to connect Rails Selenium tests to saucelabs.com.
|
5
|
+
|
6
|
+
Currently it supports tests written using Webrat, Polonium and JSUnit.
|
7
|
+
|
8
|
+
Getting Started - Webrat or Polonium test suites
|
9
|
+
------------------------------------------------
|
10
|
+
|
11
|
+
1. Prerequisites:
|
12
|
+
|
13
|
+
You must be able to run selenium tests locally using test/selenium/selenium_suite.rb
|
14
|
+
|
15
|
+
2. Install the gem:
|
16
|
+
|
17
|
+
gem install saucelabs-adapter --source gems.pivotallabs.com
|
18
|
+
|
19
|
+
3. Run the saucelabs_adapter generator in your project:
|
20
|
+
|
21
|
+
cd your_project
|
22
|
+
|
23
|
+
script/generate saucelabs_adapter
|
24
|
+
|
25
|
+
4. Configure it. In config/selenium.yml, replace YOUR-SAUCELABS-USERNAME and
|
26
|
+
YOUR-SAUCELABS-ACCESS-KEY with your saucelabs.com account information.
|
27
|
+
|
28
|
+
5. Run Tests
|
29
|
+
|
30
|
+
To run Selenium Test::Unit tests locally:
|
31
|
+
|
32
|
+
rake selenium:local
|
33
|
+
|
34
|
+
To run Selenium Test::Unit tests using saucelabs.com:
|
35
|
+
|
36
|
+
rake selenium:sauce
|
37
|
+
|
38
|
+
Getting Started - JsUnit test suite
|
39
|
+
-----------------------------------
|
40
|
+
|
41
|
+
1. Prerequisites:
|
42
|
+
|
43
|
+
Install the latest JsUnit from http://github.com/pivotal/jsunit
|
44
|
+
|
45
|
+
JsUnit must be installed in RAILS_ROOT/public/jsunit as follows:
|
46
|
+
|
47
|
+
public/jsunit/jsunit_jar/jsunit.jar -- the compiled jar
|
48
|
+
public/jsunit/jsunit/build.xml etc... -- jsunit sources
|
49
|
+
|
50
|
+
2. Install the saucelabs-adapter gem:
|
51
|
+
|
52
|
+
gem install saucelabs-adapter --source gems.pivotallabs.com
|
53
|
+
|
54
|
+
3. Run the saucelabs_adapter generator in your project:
|
55
|
+
|
56
|
+
cd your_project
|
57
|
+
|
58
|
+
script/generate saucelabs_adapter --jsunit
|
59
|
+
|
60
|
+
4. Configure it.
|
61
|
+
|
62
|
+
In config/selenium.yml, replace YOUR-SAUCELABS-USERNAME and
|
63
|
+
YOUR-SAUCELABS-ACCESS-KEY with your saucelabs.com account information.
|
64
|
+
|
65
|
+
Rename RAILS_ROOT/test/jsunit/jsunit_suite_example.rb to RAILS_ROOT/test/jsunit/jsunit_suite.rb
|
66
|
+
and modify it if necessary:
|
67
|
+
test_page needs to be set to the path under /public where your JsUnit test page (suite.html or similar) lives,
|
68
|
+
with '/jsunit' prepended. e.g. if your JsUnit suite runs from RAILS_ROOT/public/javascripts/test-pages/suite.html
|
69
|
+
then test_page needs to be set to '/jsunit/javascripts/test-pages/suite.html'.
|
70
|
+
|
71
|
+
5. Run Tests
|
72
|
+
|
73
|
+
To run JsUnit tests locally:
|
74
|
+
|
75
|
+
rake jsunit:selenium_rc:local
|
76
|
+
|
77
|
+
To run JsUnit tests using saucelabs.com:
|
78
|
+
|
79
|
+
rake jsunit:selenium_rc:sauce
|
80
|
+
|
81
|
+
What You Should See
|
82
|
+
-------------------
|
83
|
+
|
84
|
+
When running tests, intermixed with your test output you should see the following lines:
|
85
|
+
|
86
|
+
[saucelabs-adapter] Setting up tunnel from Saucelabs (yourhostname-12345.com:80) to localhost:4000
|
87
|
+
[saucelabs-adapter] Tunnel ID 717909c571b8319dc5ae708b689fd7f5 for yourhostname-12345.com is up.
|
88
|
+
Started
|
89
|
+
....................
|
90
|
+
[saucelabs-adapter] Shutting down tunnel to Saucelabs...
|
91
|
+
[saucelabs-adapter] done.
|
92
|
+
|
93
|
+
In Case of Problems
|
94
|
+
-------------------
|
95
|
+
Try setting environment variable SAUCELABS_ADAPTER_DEBUG to "true". This enables more verbose output.
|
96
|
+
|
97
|
+
|
98
|
+
Continuous Integration
|
99
|
+
----------------------
|
100
|
+
Sauce Labs now lets you set the name of a test job.
|
101
|
+
By default the SaucelabsAdapter will set this to the name of the machine it is currently running on,
|
102
|
+
however you may override this by setting the environment variable SAUCELABS_JOB_NAME.
|
103
|
+
|
104
|
+
This can be useful if you run many tests from the same CI machine and would like to differentiate between
|
105
|
+
them without actually viewing the video.
|
106
|
+
|
107
|
+
What it Does
|
108
|
+
------------
|
109
|
+
|
110
|
+
The saucelabs-adapter performs two functions when it detects you are running a test that will use saucelabs.com:
|
111
|
+
|
112
|
+
1. It sets up a SauceTunnel before the test run starts and tears it down after the test ends. This happens once for the entire test run.
|
113
|
+
|
114
|
+
2. It configures the selenium client to connect to the correct address at saucelabs.com. This happens at the start of each test.
|
115
|
+
|
116
|
+
CHANGES
|
117
|
+
=======
|
118
|
+
0.7.6
|
119
|
+
-----
|
120
|
+
- Added saucelabs_max_duration configuration option.
|
121
|
+
|
122
|
+
0.7.0
|
123
|
+
-----
|
124
|
+
- The gem has been reorganized to better conform with Gem best-practices.
|
125
|
+
|
126
|
+
- The rakefile generator has changed. If you are upgrading, you will need to rerun the generator and overwrite lib/tasks/saucelabs_adapter.rake,
|
127
|
+
or just change line 1 of that file to read:
|
128
|
+
|
129
|
+
require 'saucelabs_adapter/run_utils'
|
130
|
+
|
131
|
+
- The selenium.yml syntax has changed to break out all the saucelabs info into separate lines, and the tunnel method is now explicitly stated:
|
132
|
+
|
133
|
+
- Old:
|
134
|
+
selenium_browser_key: '{"username": "YOUR-SAUCELABS-USERNAME", "access-key": "YOUR-SAUCELABS-ACCESS-KEY", "os": "Linux", "browser": "firefox", "browser-version": "3."}'
|
135
|
+
#
|
136
|
+
localhost_app_server_port: "4000"
|
137
|
+
tunnel_startup_timeout: 240
|
138
|
+
|
139
|
+
- New:
|
140
|
+
saucelabs_username: "YOUR-SAUCELABS-USERNAME"
|
141
|
+
saucelabs_access_key: "YOUR-SAUCELABS-ACCESS-KEY"
|
142
|
+
saucelabs_browser_os: "Linux"
|
143
|
+
saucelabs_browser: "firefox"
|
144
|
+
saucelabs_browser_version: "3."
|
145
|
+
#
|
146
|
+
tunnel_method: :saucetunnel
|
147
|
+
tunnel_to_localhost_port: 4000
|
148
|
+
tunnel_startup_timeout: 240
|
149
|
+
|
150
|
+
- The dependency on Python has been removed.
|
data/Rakefile
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
|
8
|
+
desc 'Default: run unit tests.'
|
9
|
+
task :default => :spec
|
10
|
+
|
11
|
+
desc 'Test the saucelabs-adapter plugin.'
|
12
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
13
|
+
t.libs << 'lib'
|
14
|
+
t.verbose = true
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'jeweler'
|
19
|
+
Jeweler::Tasks.new do |gem|
|
20
|
+
gem.name = "saucelabs-adapter"
|
21
|
+
gem.summary = %Q{Adapter for running Selenium tests using SauceLabs.com}
|
22
|
+
gem.description = %Q{This gem augments Test::Unit and Polonium/Webrat to run Selenium tests in the cloud. }
|
23
|
+
gem.email = "pair+kelly+sam@pivotallabs.com"
|
24
|
+
gem.homepage = "http://github.com/pivotal/saucelabs-adapter"
|
25
|
+
gem.authors = ["Kelly Felkins, Chad Woolley & Sam Pierson"]
|
26
|
+
gem.files = [
|
27
|
+
"LICENSE",
|
28
|
+
"README.rdoc",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"lib/saucelabs_adapter.rb",
|
32
|
+
"lib/saucelabs-adapter.rb",
|
33
|
+
"lib/saucelabs_adapter/run_utils.rb",
|
34
|
+
"lib/saucelabs_adapter/sauce_tunnel.rb",
|
35
|
+
"lib/saucelabs_adapter/selenium_config.rb",
|
36
|
+
"lib/saucelabs_adapter/test_unit_adapter.rb",
|
37
|
+
"lib/saucelabs_adapter/jsunit_selenium_support.rb",
|
38
|
+
"lib/saucerest-ruby/saucerest.rb",
|
39
|
+
"lib/saucerest-ruby/gateway.rb",
|
40
|
+
"lib/saucerest-python/tunnel.py",
|
41
|
+
"lib/saucerest-python/daemon.py",
|
42
|
+
"lib/saucerest-python/saucerest.py",
|
43
|
+
"lib/saucerest-python/sshtunnel.py",
|
44
|
+
"lib/tasks/jsunit.rake",
|
45
|
+
"generators/saucelabs_adapter/saucelabs_adapter_generator.rb",
|
46
|
+
"generators/saucelabs_adapter/templates/selenium.yml",
|
47
|
+
"generators/saucelabs_adapter/templates/saucelabs_adapter.rake",
|
48
|
+
"generators/saucelabs_adapter/templates/jsunit.rake",
|
49
|
+
"generators/saucelabs_adapter/templates/jsunit_suite_example.rb"
|
50
|
+
]
|
51
|
+
gem.add_dependency 'rest-client', '>= 1.2.0'
|
52
|
+
gem.add_dependency 'net-ssh', '>= 2.0.12'
|
53
|
+
gem.add_dependency 'net-ssh-gateway', '>= 1.0.1'
|
54
|
+
gem.add_dependency 'selenium-client', '>= 1.2.17'
|
55
|
+
gem.add_dependency 'lsof', '>= 0.3.0'
|
56
|
+
# gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
57
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
58
|
+
end
|
59
|
+
Jeweler::GemcutterTasks.new
|
60
|
+
rescue LoadError
|
61
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
62
|
+
end
|
63
|
+
|
64
|
+
require 'rake/testtask'
|
65
|
+
Rake::TestTask.new(:test) do |test|
|
66
|
+
test.libs << 'lib' << 'test'
|
67
|
+
test.pattern = 'test/**/test_*.rb'
|
68
|
+
test.verbose = true
|
69
|
+
end
|
70
|
+
|
71
|
+
begin
|
72
|
+
require 'rcov/rcovtask'
|
73
|
+
Rcov::RcovTask.new do |test|
|
74
|
+
test.libs << 'test'
|
75
|
+
test.pattern = 'test/**/test_*.rb'
|
76
|
+
test.verbose = true
|
77
|
+
end
|
78
|
+
rescue LoadError
|
79
|
+
task :rcov do
|
80
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
task :test => :check_dependencies
|
85
|
+
|
86
|
+
#task :default => :test
|
87
|
+
|
88
|
+
require 'rake/rdoctask'
|
89
|
+
Rake::RDocTask.new do |rdoc|
|
90
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
91
|
+
|
92
|
+
rdoc.rdoc_dir = 'rdoc'
|
93
|
+
rdoc.title = "saucelabs-adapter #{version}"
|
94
|
+
rdoc.rdoc_files.include('README*')
|
95
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
96
|
+
end
|
97
|
+
|
98
|
+
def run(command)
|
99
|
+
puts command
|
100
|
+
puts `#{command}`
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Push gem to gemcutter.org"
|
104
|
+
task :deploy => :build do
|
105
|
+
gem = `ls pkg/*|tail -1`.strip
|
106
|
+
puts "Deploying #{gem}:"
|
107
|
+
run "gem push #{gem}"
|
108
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.7.6
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
# This generator bootstraps a Rails project for use with RSpec
|
3
|
+
class SaucelabsAdapterGenerator < Rails::Generator::Base
|
4
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
5
|
+
Config::CONFIG['ruby_install_name'])
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
puts <<-HELPFUL_INSTRUCTIONS
|
9
|
+
|
10
|
+
The saucelabs_adapter generator installs glue to connect your Selenium tests to saucelabs.com
|
11
|
+
|
12
|
+
After running this generator:
|
13
|
+
|
14
|
+
1) Go edit config/selenium.yml and add your SauceLabs API credentials
|
15
|
+
2) Add this to your selenium_helper.rb:
|
16
|
+
|
17
|
+
require 'saucelabs-adapter'
|
18
|
+
|
19
|
+
HELPFUL_INSTRUCTIONS
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def manifest
|
24
|
+
record do |m|
|
25
|
+
m.directory 'lib/tasks'
|
26
|
+
m.file 'saucelabs_adapter.rake', 'lib/tasks/saucelabs_adapter.rake'
|
27
|
+
m.file 'selenium.yml', 'config/selenium.yml'
|
28
|
+
if options[:jsunit]
|
29
|
+
m.file 'jsunit.rake', 'lib/tasks/jsunit.rake'
|
30
|
+
m.directory 'test/jsunit'
|
31
|
+
m.file 'jsunit_suite_example.rb', 'test/jsunit/jsunit_suite_example.rb'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
def banner
|
39
|
+
"Usage: #{$0} saucelabs_adapter [options]"
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_options!(opt)
|
43
|
+
opt.separator ''
|
44
|
+
opt.separator 'Options:'
|
45
|
+
opt.on('--jsunit', 'Also install Saucelabs support for JsUnit') do |value|
|
46
|
+
options[:jsunit] = true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'run_utils'
|
2
|
+
|
3
|
+
namespace :jsunit do
|
4
|
+
namespace :selenium_rc do
|
5
|
+
desc "Runs JsUnit tests locally using configuration 'local' in config/selenium.yml (selenium server must already be started)"
|
6
|
+
task :local => [:local_jsunit_env, :suite]
|
7
|
+
|
8
|
+
desc "Run JsUnit tests at saucelabs.com (using configuration 'saucelabs' in config/selenium.yml)"
|
9
|
+
task :sauce => [:sauce_jsunit_env, :suite]
|
10
|
+
|
11
|
+
desc "Run JsUnit tests at saucelabs.com for all supported browsers"
|
12
|
+
task :sauce_all => [:sauce_jsunit_all_env, :suite]
|
13
|
+
|
14
|
+
desc "Run Selenium tests using configuration SELENIUM_ENV (from config/selenium.yml)"
|
15
|
+
task :custom => [:check_selenium_env_is_set, :suite]
|
16
|
+
|
17
|
+
task :local_jsunit_env do
|
18
|
+
ENV['SELENIUM_ENV'] = 'local_jsunit'
|
19
|
+
end
|
20
|
+
|
21
|
+
task :sauce_jsunit_env do
|
22
|
+
ENV['SELENIUM_ENV'] = 'saucelabs_jsunit'
|
23
|
+
end
|
24
|
+
|
25
|
+
task :sauce_jsunit_all_env do
|
26
|
+
ENV['SELENIUM_ENV'] = "saucelabs_jsunit_firefox,saucelabs_jsunit_ie,saucelabs_jsunit_chrome,saucelabs_jsunit_safari"
|
27
|
+
end
|
28
|
+
|
29
|
+
task :check_selenium_env_is_set do
|
30
|
+
raise "SELENIUM_ENV must be set" unless ENV['SELENIUM_ENV']
|
31
|
+
end
|
32
|
+
|
33
|
+
task :suite do
|
34
|
+
unless (File.exists?("test/jsunit/jsunit_suite.rb"))
|
35
|
+
raise "test/jsunit/jsunit_suite.rb not found, bailing.\nPlease create a script that will run your jsunit tests."
|
36
|
+
end
|
37
|
+
ENV['RUNNING_POLONIUM'] = 'false'
|
38
|
+
|
39
|
+
# TODO: This multi-suite support is a hack and slow, but it's the easiest way to support it without major refactoring to saucelabs_adapter
|
40
|
+
env = ENV['SELENIUM_ENV']
|
41
|
+
if env =~ /,/
|
42
|
+
begin
|
43
|
+
envs = env.split(',')
|
44
|
+
envs.each do |single_env|
|
45
|
+
ENV['SELENIUM_ENV'] = single_env
|
46
|
+
run_suite
|
47
|
+
end
|
48
|
+
ensure
|
49
|
+
# make sure we reset it to avoid confusion
|
50
|
+
ENV['SELENIUM_ENV'] = env
|
51
|
+
end
|
52
|
+
else
|
53
|
+
run_suite
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_suite
|
58
|
+
success = RunUtils.run "ruby test/jsunit/jsunit_suite.rb"
|
59
|
+
raise "Jsunit suite run for #{ENV['SELENIUM_ENV']} environment failed." unless success
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
require "saucelabs_adapter"
|
3
|
+
|
4
|
+
class JsunitTest < ActiveSupport::TestCase
|
5
|
+
include ::JsunitSeleniumSupport
|
6
|
+
|
7
|
+
def setup
|
8
|
+
setup_jsunit_selenium # :timeout_in_seconds => 60, :app_server_logfile_path => "#{RAILS_ROOT}/log/jsunit_jetty_app_server.log"
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
teardown_jsunit_selenium
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_javascript
|
16
|
+
test_page = "/jsunit/javascripts/test-pages/" + (ENV['TEST'] ? "#{ENV['TEST']}.html" : "suite.html")
|
17
|
+
assert run_jsunit_test({:testPage => test_page}, :jsunit_suite_timeout_seconds => 600, :verbose => true)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'saucelabs_adapter/run_utils'
|
2
|
+
|
3
|
+
class Rake::Task
|
4
|
+
def self.exists?(name)
|
5
|
+
tasks.any? { |t| t.name == name }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :selenium do
|
10
|
+
|
11
|
+
# Rake tasks are cumulative, and some old plugins are still defining selenium:server, so clear it.
|
12
|
+
Rake::Task[:'selenium:server'].clear_actions if Rake::Task.exists?('selenium:server')
|
13
|
+
|
14
|
+
desc "Run the selenium remote-control server"
|
15
|
+
task :server do
|
16
|
+
system('selenium-rc')
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Run the selenium remote-control server in the background"
|
20
|
+
task :server_bg do
|
21
|
+
system('nohup selenium-rc 2&>1 &')
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Runs Selenium tests locally (selenium server must already be started)"
|
25
|
+
task :local => [:local_env, :suite]
|
26
|
+
|
27
|
+
desc "Run Selenium tests at saucelabs.com (using configuration 'saucelabs' in config/selenium.yml)"
|
28
|
+
task :sauce => [:sauce_env, :suite]
|
29
|
+
|
30
|
+
desc "Run Selenium tests using configuration SELENIUM_ENV (from config/selenium.yml)"
|
31
|
+
task :custom => [:check_selenium_env_is_set, :suite]
|
32
|
+
|
33
|
+
task :local_env do
|
34
|
+
ENV['SELENIUM_ENV'] = 'local'
|
35
|
+
end
|
36
|
+
|
37
|
+
task :sauce_env do
|
38
|
+
ENV['SELENIUM_ENV'] = 'saucelabs'
|
39
|
+
end
|
40
|
+
|
41
|
+
task :check_selenium_env_is_set do
|
42
|
+
raise "SELENIUM_ENV must be set" unless ENV['SELENIUM_ENV']
|
43
|
+
end
|
44
|
+
|
45
|
+
task :suite do
|
46
|
+
if (File.exists?("test/selenium/selenium_suite.rb"))
|
47
|
+
RunUtils.run "ruby test/selenium/selenium_suite.rb"
|
48
|
+
else
|
49
|
+
puts "test/selenium/selenium_suite.rb not found, bailing.\nPlease create a script that will run your selenium tests."
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|