{}[http://travis-ci.org/testingbot/testingbot_ruby] = TestingBot Testingbot.com is a website where you can use our cloud based Selenium grid. Test your web applications in various environments/browsers/devices. == How to install? You can install our testingbot ruby-gem by running "gem install testingbot" on your commandline. $ gem install testingbot == Setup After you installed the gem you need to run a one part setup. Type testingbot in your commandline and fill in the API key and API secret you obtained on http://testingbot.com $ testingbot == Usage === Example Test::Unit You can find an example in our examples folder, try something like this: require "rubygems" require "test/unit" require "testingbot" class ExampleTest < TestingBot::TestCase attr_reader :browser def setup @browser = Selenium::Client::Driver.new \ :browser => "firefox", :url => "http://www.google.com", :platform => "WINDOWS", :version => 10, :timeout_in_second => 90 browser.start_new_browser_session end def teardown browser.close_current_browser_session end def test_page_search browser.open "/" assert_equal "Google", browser.title end end === Example RSpec 2 This example uses RSpec 2. You can run it with rspec test_rspec.rb require 'rubygems' require "selenium/client" require 'rspec' require 'testingbot' require 'testingbot/tunnel' # rspec 2 describe "People", :type => :selenium do attr_reader :selenium_driver before(:all) do # uncomment if you want to use our Tunnel # tunnel = TestingBot::Tunnel.new # tunnel.start @selenium_driver = Selenium::Client::Driver.new \ :browser => "firefox", :url => "http://www.google.com", :timeout_in_second => 60, :platform => "WINDOWS", :version => "10" end before(:each) do @selenium_driver.start_new_browser_session end after(:each) do @selenium_driver.close_current_browser_session end it "can find the right title" do @selenium_driver.open "/" @selenium_driver.title.should eql("Google") end end === Example RSpec 1 This example uses RSpec 1. You can run it with spec test_rspec1.rb require 'rubygems' gem "rspec", "<2" gem "selenium-client" require "selenium/client" require "selenium/rspec/spec_helper" gem "testingbot" require "testingbot" describe "Test" do attr_reader :selenium_driver alias :page :selenium_driver before(:all) do @selenium_driver = Selenium::Client::Driver.new \ :browser => "firefox", :url => "http://www.google.com", :timeout_in_second => 90, :platform => "WINDOWS", :version => "10" end before(:each) do @selenium_driver.start_new_browser_session end append_after(:each) do @selenium_driver.close_current_browser_session end it "can find the right title" do page.open "/" page.title.should eql("Google") end end === Example RSpec 2 and Capybara This example uses RSpec 2 together with capybara and Selenium webdriver. You can run it with rspec capybara.rb require 'rspec' require 'capybara/rspec' require 'testingbot' require 'testingbot/capybara' TestingBot::config do |config| config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS" } # config.require_tunnel # uncomment if you want to use our Tunnel end describe "People", :type => :request do before :each do Capybara.current_driver = :testingbot Capybara.app_host = "http://testingbot.com" end it 'has a homepage with the word Selenium' do visit '/' page.should have_content('Selenium') end end === Example RSpec 2, Capybara and Rails In this example we will need rspec-rails and Capybara, a rack server will be started by Capybara to run your localhost tests. Add the example below in spec/integration/home_spec.rb ---------------------------------------------------------- spec_helper.rb: require 'capybara/rspec' require 'capybara/rails' require 'testingbot' require 'testingbot/capybara' ---------------------------------------------------------- spec/integration/home_spec.rb: require 'spec_helper' TestingBot::config do |config| config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS", :localhost => "YES" } config.require_tunnel end describe 'home page' do before :each do Capybara.server_port = 3011 Capybara.current_driver = :testingbot Capybara.app_host = "http://127.0.0.1:3011" end after :each do # this is a workaround to push test status/details back to testingbot # we need to use this because capybara overwrites the driver with a rack-test driver @selenium_driver = page.driver.browser.send(:bridge) end it "shows the home page", :type => :request do visit '/' page.should have_content('Selenium') end end === Example RSpec 2 run on multiple browsers Use the :multibrowser => true statement to indicate you want to test on multiple browsers. This should work together with Capybara as well. require 'rubygems' require "selenium/client" require 'rspec' require 'testingbot' require 'testingbot/tunnel' TestingBot::config do |config| config[:desired_capabilities] = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 11, :platform => "WINDOWS" }] end describe "Google", :type => :selenium, :multibrowser => true do it "can find the right title" do page.navigate.to "http://www.google.com" page.title.should eql("Google") end end == Capybara and Cucumber The examples directory contains an example of testing with Capybara and Cucumber. The Rakefile in examples/cucumber contains a cucumber task which will run the same Cucumber story on multiple browsers. More info available on http://testingbot.com/support/getting-started/cucumber.html == Test this gem The tests for this gem are located in the spec folder, you can run them with this Rake task: rake spec == Extra options You can specify extra options like enabling/disabling the screenrecording or screenshot feature. For WebDriver use the config[:desired_capabilities] to specify extra options. For RC tests use the start_new_browser_session(options) options hash. == More information Get more information on http://testingbot.com == Copyright Copyright (c) TestingBot Please see our LICENSE