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
- 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
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n