1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/README.rdoc

105 lines
3.5 KiB
Text
Raw Normal View History

2009-11-04 17:00:05 -05:00
= webcat
* http://github.com/jnicklas/webcat
2009-11-14 09:31:44 -05:00
== Description:
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
Webcat is a unified API for writing web application integration tests for Rack
applications. It works with any rack application and currently has support for
Culerity, Selenium and rack-test.
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
== Install:
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
Clone and install from github for now
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
== Getting Started:
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
You can initialize a session and start issuing commands:
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
require 'webcat'
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
session = Webcat::Session.new(:culerity, my_rack_app)
session.within("//form[@id='session']") do
session.fill_in 'Login', :with => 'user@example.com'
session.fill_in 'Password', :with => 'password'
end
session.click_link 'Sign in'
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
Webcat provides a terser DSL:
2009-11-04 17:00:05 -05:00
2009-11-14 20:13:07 -05:00
require 'webcat'
require 'webcat/dsl'
include Webcat
Webcat.default_driver = :culerity
within("//form[@id='session']") do
fill_in 'Login', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_link 'Sign in'
If you want to use it with Cucumber, just require:
require 'webcat/cucumber'
Webcat.app = my_rack_app
Then write your steps like this:
When /I sign in/ do
within("//form[@id='session']") do
fill_in 'Login', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_link 'Sign in'
end
If you're using Rails, webcan can set up the rack app for you. Just do:
require 'webcat/cucumber'
require 'webcat/rails'
== Gotchas:
* Everything is *case sensitive*. Webcat heavily relies on XPath, which doesn't
support case insensitive searches.
* Unchecking checkboxes and filling in password fields is currently broken
under Culerity.
* Domain names (including subdomains) don't work under rack-test. Since it's a
pain to set up subdomains for the other drivers anyway, you should consider
an alternate solution. See for example [GIST here].
* The set_hidden_field method from Webrat is not implemented, since it doesn't
work in any of the browser based drivers (Culerity, Selenium)
* Access to session, request and response from the test is not possible. Maybe
we'll do response headers at some point in the future, but the others really
shouldn't be touched in an integration test anyway.
* Access to Rails specific stuff (such as +controller+) is unavailable, since
we're not using Rails' integration testing.
2009-11-16 14:11:21 -05:00
* <a href="#"> Will cause problems under rack-test, please do
<a href="/same/url#"> instead. You can achieve this in Rails with
+link_to('foo', :anchor => '')+
2009-11-04 17:00:05 -05:00
2009-11-14 09:31:44 -05:00
== License:
2009-11-04 17:00:05 -05:00
(The MIT License)
Copyright (c) 2009 Jonas Nicklas
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.