selenium, ymls, a sample test
This commit is contained in:
parent
36b2445a11
commit
20678060e7
7 changed files with 163 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
|||
.idea
|
||||
*.swap
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
|
|
|||
5
Gemfile
5
Gemfile
|
|
@ -40,11 +40,14 @@ group :test do
|
|||
gem 'rspec', '>= 2.0.0.beta.17'
|
||||
gem 'rspec-rails', '2.0.0.beta.17'
|
||||
gem 'mocha'
|
||||
gem 'webrat'
|
||||
gem 'webrat', '0.7.2.beta.1'
|
||||
gem 'redgreen'
|
||||
gem 'autotest'
|
||||
gem 'factory_girl_rails'
|
||||
gem 'database_cleaner'
|
||||
gem 'saucelabs-adapter', '= 0.8.12'
|
||||
gem 'selenium-rc'
|
||||
gem 'json'
|
||||
end
|
||||
|
||||
group :development do
|
||||
|
|
|
|||
86
config/selenium.yml
Normal file
86
config/selenium.yml
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
common: &common
|
||||
# Try to kill mongrel after suite if tmp/pids/mongrel_selenium.pid exists
|
||||
# kill_mongrel_after_suite: true
|
||||
|
||||
local: &local
|
||||
<<: *common
|
||||
test_framework: webrat
|
||||
selenium_server_address: "127.0.0.1"
|
||||
selenium_server_port: "4444"
|
||||
selenium_browser_key: "*chrome /Applications/Firefox.app/Contents/MacOS/firefox-bin"
|
||||
application_address: "127.0.0.1"
|
||||
application_port: "4000"
|
||||
|
||||
local_jsunit:
|
||||
<<: *local
|
||||
application_port: "8080"
|
||||
|
||||
# Possible Sauce Labs configurations as of 2009/11/19
|
||||
# From: http://saucelabs.com/products/docs/sauce-ondemand/browsers
|
||||
#
|
||||
# saucelabs_browser_os saucelabs_browser saucelabs_browser_version (pick one)
|
||||
#
|
||||
# "Windows 2003" "iexplore" "6.", "7.", "8."
|
||||
# "firefox" "2.", "3.0", "3.5"
|
||||
# "safari" "3.", "4."
|
||||
# "opera" "9."
|
||||
# "googlechrome" ""
|
||||
# "Linux" "firefox" "3."
|
||||
saucelabs: &saucelabs
|
||||
<<: *common
|
||||
test_framework: webrat
|
||||
# URL of Selenium RC server:
|
||||
selenium_server_address: "saucelabs.com"
|
||||
selenium_server_port: "4444"
|
||||
# Saucelabs credentials / Browser to drive
|
||||
saucelabs_username: "YOUR-SAUCELABS-USERNAME"
|
||||
saucelabs_access_key: "YOUR-SAUCELABS-ACCESS-KEY"
|
||||
saucelabs_browser_os: "Linux"
|
||||
saucelabs_browser: "firefox"
|
||||
saucelabs_browser_version: "3."
|
||||
saucelabs_max_duration_seconds: 1800
|
||||
# Selenium RC browser connects to and tests the app at this URL:
|
||||
application_address: "testhost.com" # this will be ovewritten if tunnel_method == :saucetunnel
|
||||
application_port: 80
|
||||
# App host can actually be a tunnel that tunnels from <application_address>:<application_port> to localhost:<tunnel_to_localhost_port>
|
||||
# There are 3 kinds of tunnels:
|
||||
#
|
||||
# tunnel_method: :saucetunnel
|
||||
# tunnel_to_localhost_port: 4000 # Warning: application_port and tunnel_to_localhost_port must be identical if you are using Webrat
|
||||
# tunnel_startup_timeout: 240
|
||||
#
|
||||
# tunnel_method: :sshtunnel
|
||||
# application_address: proxy.mycompany.com
|
||||
# application_port: 12345 # or can be a range XXXX-YYYY
|
||||
# tunnel_to_localhost_port: 4000 # Warning: application_port and tunnel_to_localhost_port must be identical if you are using Webrat
|
||||
# tunnel_username: fred
|
||||
# tunnel_keyfile: "/Users/<%= ENV['USER'] %>/.ssh/id_rsa" # or tunnel_password: "password"
|
||||
#
|
||||
# tunnel_method: :othertunnel You're managing your tunnel independently
|
||||
|
||||
saucelabs_jsunit: &saucelabs_jsunit
|
||||
<<: *saucelabs
|
||||
# We are using the Jetty server for Saucelabs JsUnit selenium testing.
|
||||
localhost_app_server_port: "8080"
|
||||
|
||||
saucelabs_jsunit_firefox:
|
||||
<<: *saucelabs_jsunit
|
||||
|
||||
saucelabs_jsunit_ie:
|
||||
<<: *saucelabs_jsunit
|
||||
saucelabs_browser_os: "Windows 2003"
|
||||
saucelabs_browser: "iexplore"
|
||||
saucelabs_browser_version: "7."
|
||||
jsunit_polling_interval_seconds: 300
|
||||
|
||||
saucelabs_jsunit_safari:
|
||||
<<: *saucelabs_jsunit
|
||||
saucelabs_browser_os: "Windows 2003"
|
||||
saucelabs_browser: "safari"
|
||||
saucelabs_browser_version: "4."
|
||||
|
||||
saucelabs_jsunit_chrome:
|
||||
<<: *saucelabs_jsunit
|
||||
saucelabs_browser_os: "Windows 2003"
|
||||
saucelabs_browser: "googlechrome"
|
||||
saucelabs_browser_version: ""
|
||||
53
lib/tasks/saucelabs_adapter.rake
Normal file
53
lib/tasks/saucelabs_adapter.rake
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
require 'saucelabs_adapter/run_utils'
|
||||
|
||||
class Rake::Task
|
||||
def self.exists?(name)
|
||||
tasks.any? { |t| t.name == name }
|
||||
end
|
||||
end
|
||||
|
||||
namespace :selenium do
|
||||
|
||||
# Rake tasks are cumulative, and some old plugins are still defining selenium:server, so clear it.
|
||||
Rake::Task[:'selenium:server'].clear_actions if Rake::Task.exists?('selenium:server')
|
||||
|
||||
desc "Run the selenium remote-control server"
|
||||
task :server do
|
||||
system('bundle exec selenium-rc')
|
||||
end
|
||||
|
||||
desc "Run the selenium remote-control server in the background"
|
||||
task :server_bg do
|
||||
system('nohup selenium-rc 2&>1 &')
|
||||
end
|
||||
|
||||
desc "Runs Selenium tests locally (selenium server must already be started)"
|
||||
task :local => [:local_env, :suite]
|
||||
|
||||
desc "Run Selenium tests at saucelabs.com (using configuration 'saucelabs' in config/selenium.yml)"
|
||||
task :sauce => [:sauce_env, :suite]
|
||||
|
||||
desc "Run Selenium tests using configuration SELENIUM_ENV (from config/selenium.yml)"
|
||||
task :custom => [:check_selenium_env_is_set, :suite]
|
||||
|
||||
task :local_env do
|
||||
ENV['SELENIUM_ENV'] = 'local'
|
||||
end
|
||||
|
||||
task :sauce_env do
|
||||
ENV['SELENIUM_ENV'] = 'saucelabs'
|
||||
end
|
||||
|
||||
task :check_selenium_env_is_set do
|
||||
raise "SELENIUM_ENV must be set" unless ENV['SELENIUM_ENV']
|
||||
end
|
||||
|
||||
task :suite do
|
||||
if (File.exists?("test/selenium/selenium_suite.rb"))
|
||||
RunUtils.run "ruby test/selenium/selenium_suite.rb"
|
||||
else
|
||||
puts "test/selenium/selenium_suite.rb not found, bailing.\nPlease create a script that will run your selenium tests."
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
end
|
||||
7
test/selenium/sample_webrat_test.rb
Normal file
7
test/selenium/sample_webrat_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class SampleWebratTest < ActionController::IntegrationTest
|
||||
|
||||
def test_widget
|
||||
visit "/"
|
||||
assert_contain "sign in"
|
||||
end
|
||||
end
|
||||
11
test/selenium/selenium_suite.rb
Normal file
11
test/selenium/selenium_suite.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
||||
require 'test/unit/ui/console/testrunner'
|
||||
require 'webrat'
|
||||
require 'saucelabs_adapter'
|
||||
|
||||
Webrat.configure do |config|
|
||||
config.mode = :selenium
|
||||
config.application_framework = :rack
|
||||
end
|
||||
|
||||
require File.join(File.dirname(__FILE__), 'sample_webrat_test')
|
||||
|
|
@ -7,7 +7,7 @@ class ActiveSupport::TestCase
|
|||
#
|
||||
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
||||
# -- they do not yet inherit this setting
|
||||
fixtures :all
|
||||
#fixtures :all
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue