SlideShare a Scribd company logo
Capybara
backend for
  Ruby DSL                              Cucumber
                  Capybara
                  driver agnostic

  RackTest -                        Selenium - default
default browser                      javascript driver
set it up !!

sudo gem install capybara

rails app : rails generate cucumber:install --
capybara

non rails app :

   require 'capybara/cucumber'

   Capybara.app = MyRackApp

https://github.com/jnicklas/capybara
all about drivers
Capybara.javascript_driver = :selenium

Capybara.default_driver = :selenium

register new driver

  Capybara.register_driver :celerity do |app|
  Capybara::Driver::Celerity.new(app,:browser
  => :chrome) end

Currently supported drivers

  RackTest

  Selenium 2.0 - Webdriver

  HtmlUnit - Akephalos, Celerity, Culerity

  Capybara-webkit
capybara dsl
navigation - visit

clicks - click_link

finders - find_field

matchers - page.has_xpath?

actions - fill_in

scope - within

scripting - page.execute_script()

http://rubydoc.info/github/jnicklas/capybara/master
google_steps.rb


When /^I search google for "([^"]*)"$/ do |search_string|
      visit("http://google.com")
      fill_in ('q', :with => search_string)
      click_button ('Search')
end


Then /google should .+ "([^"]*)"/ do |expected_substring|
      page.should have_content(expected_substring)
end
reduce build time


tagging

use headless webdriver
what else?
capybara-firebug

use capybara with rspec

run on remote server using

    Capybara.run_server = false

supports both xpath and css

http://google-opensource.blogspot.com/2009/05/introducing-
webdriver.html

More Related Content

Capybara

  • 2. backend for Ruby DSL Cucumber Capybara driver agnostic RackTest - Selenium - default default browser javascript driver
  • 3. set it up !! sudo gem install capybara rails app : rails generate cucumber:install -- capybara non rails app : require 'capybara/cucumber' Capybara.app = MyRackApp https://github.com/jnicklas/capybara
  • 4. all about drivers Capybara.javascript_driver = :selenium Capybara.default_driver = :selenium register new driver Capybara.register_driver :celerity do |app| Capybara::Driver::Celerity.new(app,:browser => :chrome) end Currently supported drivers RackTest Selenium 2.0 - Webdriver HtmlUnit - Akephalos, Celerity, Culerity Capybara-webkit
  • 5. capybara dsl navigation - visit clicks - click_link finders - find_field matchers - page.has_xpath? actions - fill_in scope - within scripting - page.execute_script() http://rubydoc.info/github/jnicklas/capybara/master
  • 6. google_steps.rb When /^I search google for "([^"]*)"$/ do |search_string| visit("http://google.com") fill_in ('q', :with => search_string) click_button ('Search') end Then /google should .+ "([^"]*)"/ do |expected_substring| page.should have_content(expected_substring) end
  • 7. reduce build time tagging use headless webdriver
  • 8. what else? capybara-firebug use capybara with rspec run on remote server using Capybara.run_server = false supports both xpath and css http://google-opensource.blogspot.com/2009/05/introducing- webdriver.html

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n