mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
don't suggest including Capybara in the global object, closes #63
This commit is contained in:
parent
0144e04ae1
commit
360088a369
1 changed files with 11 additions and 10 deletions
21
README.rdoc
21
README.rdoc
|
@ -276,26 +276,27 @@ examples. Just load the DSL and include it anywhere:
|
|||
require 'capybara'
|
||||
require 'capybara/dsl'
|
||||
|
||||
include Capybara
|
||||
Capybara.default_driver = :culerity
|
||||
|
||||
within("//form[@id='session']") do
|
||||
fill_in 'Login', :with => 'user@example.com'
|
||||
fill_in 'Password', :with => 'password'
|
||||
module MyModule
|
||||
include Capybara
|
||||
|
||||
def login!
|
||||
within("//form[@id='session']") do
|
||||
fill_in 'Login', :with => 'user@example.com'
|
||||
fill_in 'Password', :with => 'password'
|
||||
end
|
||||
click_link 'Sign in'
|
||||
end
|
||||
end
|
||||
click_link 'Sign in'
|
||||
|
||||
== Calling remote servers
|
||||
|
||||
Normally Capybara expects to be testing an in-process Rack application, but you can also use it to talk to a web server running anywhere on the internets, by setting app_host:
|
||||
|
||||
require 'capybara'
|
||||
require 'capybara/dsl'
|
||||
|
||||
include Capybara
|
||||
Capybara.current_driver = :selenium
|
||||
Capybara.app_host = 'http://www.google.com'
|
||||
|
||||
...
|
||||
visit('/')
|
||||
|
||||
Note that rack-test does not support running against a remote server. With drivers that support it, you can also visit any URL directly:
|
||||
|
|
Loading…
Reference in a new issue