capybara 0.3.0 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +4 -0
- data/README.rdoc +45 -5
- data/lib/capybara.rb +11 -4
- data/lib/capybara/driver/base.rb +3 -0
- data/lib/capybara/driver/celerity_driver.rb +44 -9
- data/lib/capybara/driver/rack_test_driver.rb +80 -16
- data/lib/capybara/driver/selenium_driver.rb +41 -9
- data/lib/capybara/dsl.rb +4 -10
- data/lib/capybara/node.rb +8 -0
- data/lib/capybara/rails.rb +8 -2
- data/lib/capybara/save_and_open_page.rb +5 -1
- data/lib/capybara/searchable.rb +17 -9
- data/lib/capybara/server.rb +35 -23
- data/lib/capybara/session.rb +91 -22
- data/lib/capybara/xpath.rb +66 -27
- data/spec/driver/celerity_driver_spec.rb +2 -2
- data/spec/driver/culerity_driver_spec.rb +1 -2
- data/spec/driver/rack_test_driver_spec.rb +0 -1
- data/spec/driver/remote_culerity_driver_spec.rb +9 -5
- data/spec/driver/selenium_driver_spec.rb +0 -1
- data/spec/drivers_spec.rb +24 -32
- data/spec/dsl/all_spec.rb +56 -25
- data/spec/dsl/attach_file_spec.rb +49 -51
- data/spec/dsl/check_spec.rb +12 -1
- data/spec/dsl/choose_spec.rb +19 -21
- data/spec/dsl/click_button_spec.rb +140 -87
- data/spec/dsl/click_link_spec.rb +88 -68
- data/spec/dsl/click_spec.rb +20 -22
- data/spec/dsl/current_url_spec.rb +6 -8
- data/spec/dsl/fill_in_spec.rb +75 -67
- data/spec/dsl/find_button_spec.rb +12 -14
- data/spec/dsl/find_by_id_spec.rb +16 -0
- data/spec/dsl/find_field_spec.rb +17 -19
- data/spec/dsl/find_link_spec.rb +13 -15
- data/spec/dsl/find_spec.rb +44 -23
- data/spec/dsl/has_button_spec.rb +32 -0
- data/spec/dsl/has_content_spec.rb +79 -81
- data/spec/dsl/has_css_spec.rb +81 -83
- data/spec/dsl/has_field_spec.rb +96 -0
- data/spec/dsl/has_link_spec.rb +33 -0
- data/spec/dsl/has_xpath_spec.rb +97 -89
- data/spec/dsl/locate_spec.rb +47 -26
- data/spec/dsl/select_spec.rb +61 -17
- data/spec/dsl/uncheck_spec.rb +17 -25
- data/spec/dsl/within_spec.rb +112 -104
- data/spec/public/test.js +3 -0
- data/spec/searchable_spec.rb +1 -1
- data/spec/server_spec.rb +7 -7
- data/spec/session/celerity_session_spec.rb +2 -2
- data/spec/session/culerity_session_spec.rb +1 -1
- data/spec/session_spec.rb +7 -0
- data/spec/session_with_javascript_support_spec.rb +139 -120
- data/spec/spec_helper.rb +7 -2
- data/spec/test_app.rb +8 -4
- data/spec/views/form.erb +50 -2
- data/spec/views/tables.erb +61 -1
- data/spec/views/with_html.erb +8 -2
- data/spec/views/with_js.erb +4 -0
- data/spec/xpath_spec.rb +17 -0
- metadata +6 -2
data/spec/dsl/uncheck_spec.rb
CHANGED
@@ -1,29 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should uncheck a checkbox by id" do
|
9
|
-
@session.uncheck("form_pets_hamster")
|
10
|
-
@session.click_button('awesome')
|
11
|
-
extract_results(@session)['pets'].should include('dog')
|
12
|
-
extract_results(@session)['pets'].should_not include('hamster')
|
13
|
-
end
|
1
|
+
shared_examples_for "uncheck" do
|
2
|
+
describe "#uncheck" do
|
3
|
+
before do
|
4
|
+
@session.visit('/form')
|
5
|
+
end
|
14
6
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
7
|
+
it "should uncheck a checkbox by id" do
|
8
|
+
@session.uncheck("form_pets_hamster")
|
9
|
+
@session.click_button('awesome')
|
10
|
+
extract_results(@session)['pets'].should include('dog')
|
11
|
+
extract_results(@session)['pets'].should_not include('hamster')
|
12
|
+
end
|
21
13
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
it "should uncheck a checkbox by label" do
|
15
|
+
@session.uncheck("Hamster")
|
16
|
+
@session.click_button('awesome')
|
17
|
+
extract_results(@session)['pets'].should include('dog')
|
18
|
+
extract_results(@session)['pets'].should_not include('hamster')
|
27
19
|
end
|
28
20
|
end
|
29
|
-
end
|
21
|
+
end
|
data/spec/dsl/within_spec.rb
CHANGED
@@ -1,145 +1,153 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
1
|
+
shared_examples_for "within" do
|
2
|
+
describe '#within' do
|
3
|
+
before do
|
4
|
+
@session.visit('/with_scope')
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
@session.body.should include('Bar')
|
7
|
+
context "with CSS selector" do
|
8
|
+
it "should click links in the given scope" do
|
9
|
+
@session.within(:css, "ul li[contains('With Simple HTML')]") do
|
10
|
+
@session.click_link('Go')
|
14
11
|
end
|
12
|
+
@session.body.should include('Bar')
|
15
13
|
end
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
@session.body.should include('Bar')
|
16
|
+
context "with XPath selector" do
|
17
|
+
it "should click links in the given scope" do
|
18
|
+
@session.within(:xpath, "//li[contains(.,'With Simple HTML')]") do
|
19
|
+
@session.click_link('Go')
|
23
20
|
end
|
21
|
+
@session.body.should include('Bar')
|
24
22
|
end
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
@session.body.should include('Bar')
|
25
|
+
context "with the default selector" do
|
26
|
+
it "should use XPath" do
|
27
|
+
@session.within("//li[contains(., 'With Simple HTML')]") do
|
28
|
+
@session.click_link('Go')
|
32
29
|
end
|
30
|
+
@session.body.should include('Bar')
|
33
31
|
end
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
it "should use CSS" do
|
41
|
-
Capybara.default_selector = :css
|
42
|
-
@session.within("ul li[contains('With Simple HTML')]") do
|
43
|
-
@session.click_link('Go')
|
44
|
-
end
|
45
|
-
@session.body.should include('Bar')
|
34
|
+
context "with the default selector set to CSS" do
|
35
|
+
before { Capybara.default_selector = :css }
|
36
|
+
it "should use CSS" do
|
37
|
+
@session.within("ul li[contains('With Simple HTML')]") do
|
38
|
+
@session.click_link('Go')
|
46
39
|
end
|
40
|
+
@session.body.should include('Bar')
|
47
41
|
end
|
42
|
+
after { Capybara.default_selector = :xpath }
|
43
|
+
end
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
@session.body.should include('Bar')
|
45
|
+
context "with click_link" do
|
46
|
+
it "should click links in the given scope" do
|
47
|
+
@session.within("//li[contains(.,'With Simple HTML')]") do
|
48
|
+
@session.click_link('Go')
|
55
49
|
end
|
50
|
+
@session.body.should include('Bar')
|
51
|
+
end
|
56
52
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
@session.body.should include('Another World')
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should respect the outer scope" do
|
68
|
-
@session.within("//div[@id='another_foo']") do
|
69
|
-
@session.within("//li[contains(.,'With Simple HTML')]") do
|
70
|
-
@session.click_link('Go')
|
71
|
-
end
|
53
|
+
context "with nested scopes" do
|
54
|
+
it "should respect the inner scope" do
|
55
|
+
@session.within("//div[@id='for_bar']") do
|
56
|
+
@session.within("//li[contains(.,'Bar')]") do
|
57
|
+
@session.click_link('Go')
|
72
58
|
end
|
73
|
-
@session.body.should include('Hello world')
|
74
59
|
end
|
60
|
+
@session.body.should include('Another World')
|
75
61
|
end
|
76
62
|
|
77
|
-
it "should
|
78
|
-
|
79
|
-
@session.within("//
|
63
|
+
it "should respect the outer scope" do
|
64
|
+
@session.within("//div[@id='another_foo']") do
|
65
|
+
@session.within("//li[contains(.,'With Simple HTML')]") do
|
66
|
+
@session.click_link('Go')
|
80
67
|
end
|
81
|
-
|
68
|
+
end
|
69
|
+
@session.body.should include('Hello world')
|
82
70
|
end
|
83
71
|
end
|
84
72
|
|
85
|
-
|
86
|
-
|
87
|
-
@session.within("//
|
88
|
-
@session.click_button('Go')
|
73
|
+
it "should raise an error if the scope is not found on the page" do
|
74
|
+
running {
|
75
|
+
@session.within("//div[@id='doesnotexist']") do
|
89
76
|
end
|
90
|
-
|
91
|
-
@session.visit('/with_scope')
|
92
|
-
@session.within("//li[contains(.,'Bar')]") do
|
93
|
-
@session.fill_in('First Name', :with => 'Dagobert')
|
94
|
-
@session.click_button('Go')
|
95
|
-
end
|
96
|
-
extract_results(@session)['first_name'].should == 'Dagobert'
|
97
|
-
end
|
77
|
+
}.should raise_error(Capybara::ElementNotFound)
|
98
78
|
end
|
99
|
-
end
|
100
79
|
|
101
|
-
|
102
|
-
|
103
|
-
|
80
|
+
it "should restore the scope when an error is raised" do
|
81
|
+
running {
|
82
|
+
@session.within("//div[@id='for_bar']") do
|
83
|
+
running {
|
84
|
+
running {
|
85
|
+
@session.within("//div[@id='doesnotexist']") do
|
86
|
+
end
|
87
|
+
}.should raise_error(Capybara::ElementNotFound)
|
88
|
+
}.should_not change { @session.has_xpath?("//div[@id='another_foo']") }.from(false)
|
89
|
+
end
|
90
|
+
}.should_not change { @session.has_xpath?("//div[@id='another_foo']") }.from(true)
|
104
91
|
end
|
92
|
+
end
|
105
93
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
@session.click_button(
|
94
|
+
context "with forms" do
|
95
|
+
it "should fill in a field and click a button" do
|
96
|
+
@session.within("//li[contains(.,'Bar')]") do
|
97
|
+
@session.click_button('Go')
|
110
98
|
end
|
111
|
-
extract_results(@session)['
|
99
|
+
extract_results(@session)['first_name'].should == 'Peter'
|
100
|
+
@session.visit('/with_scope')
|
101
|
+
@session.within("//li[contains(.,'Bar')]") do
|
102
|
+
@session.fill_in('First Name', :with => 'Dagobert')
|
103
|
+
@session.click_button('Go')
|
104
|
+
end
|
105
|
+
extract_results(@session)['first_name'].should == 'Dagobert'
|
112
106
|
end
|
107
|
+
end
|
108
|
+
end
|
113
109
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
110
|
+
describe '#within_fieldset' do
|
111
|
+
before do
|
112
|
+
@session.visit('/fieldsets')
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should restrict scope to a fieldset given by id" do
|
116
|
+
@session.within_fieldset("villain_fieldset") do
|
117
|
+
@session.fill_in("Name", :with => 'Goldfinger')
|
118
|
+
@session.click_button("Create")
|
120
119
|
end
|
120
|
+
extract_results(@session)['villain_name'].should == 'Goldfinger'
|
121
121
|
end
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
@session.
|
123
|
+
it "should restrict scope to a fieldset given by legend" do
|
124
|
+
@session.within_fieldset("Villain") do
|
125
|
+
@session.fill_in("Name", :with => 'Goldfinger')
|
126
|
+
@session.click_button("Create")
|
126
127
|
end
|
128
|
+
extract_results(@session)['villain_name'].should == 'Goldfinger'
|
129
|
+
end
|
130
|
+
end
|
127
131
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
132
|
+
describe '#within_table' do
|
133
|
+
before do
|
134
|
+
@session.visit('/tables')
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should restrict scope to a fieldset given by id" do
|
138
|
+
@session.within_table("girl_table") do
|
139
|
+
@session.fill_in("Name", :with => 'Christmas')
|
140
|
+
@session.click_button("Create")
|
134
141
|
end
|
142
|
+
extract_results(@session)['girl_name'].should == 'Christmas'
|
143
|
+
end
|
135
144
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
141
|
-
extract_results(@session)['villain_name'].should == 'Quantum'
|
145
|
+
it "should restrict scope to a fieldset given by legend" do
|
146
|
+
@session.within_table("Villain") do
|
147
|
+
@session.fill_in("Name", :with => 'Quantum')
|
148
|
+
@session.click_button("Create")
|
142
149
|
end
|
150
|
+
extract_results(@session)['villain_name'].should == 'Quantum'
|
143
151
|
end
|
144
152
|
end
|
145
|
-
end
|
153
|
+
end
|
data/spec/public/test.js
CHANGED
data/spec/searchable_spec.rb
CHANGED
data/spec/server_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe Capybara::Server do
|
|
4
4
|
|
5
5
|
it "should spool up a rack server" do
|
6
6
|
@app = proc { |env| [200, {}, "Hello Server!"]}
|
7
|
-
@server = Capybara::Server.new(@app)
|
7
|
+
@server = Capybara::Server.new(@app).boot
|
8
8
|
|
9
9
|
@res = Net::HTTP.start(@server.host, @server.port) { |http| http.get('/') }
|
10
10
|
|
@@ -15,8 +15,8 @@ describe Capybara::Server do
|
|
15
15
|
@app1 = proc { |env| [200, {}, "Hello Server!"]}
|
16
16
|
@app2 = proc { |env| [200, {}, "Hello Second Server!"]}
|
17
17
|
|
18
|
-
@server1 = Capybara::Server.new(@app1)
|
19
|
-
@server2 = Capybara::Server.new(@app2)
|
18
|
+
@server1 = Capybara::Server.new(@app1).boot
|
19
|
+
@server2 = Capybara::Server.new(@app2).boot
|
20
20
|
|
21
21
|
@res1 = Net::HTTP.start(@server1.host, @server1.port) { |http| http.get('/') }
|
22
22
|
@res1.body.should include('Hello Server')
|
@@ -29,10 +29,10 @@ describe Capybara::Server do
|
|
29
29
|
@app1 = proc { |env| [200, {}, "Hello Server!"]}
|
30
30
|
@app2 = proc { |env| [200, {}, "Hello Second Server!"]}
|
31
31
|
|
32
|
-
@server1a = Capybara::Server.new(@app1)
|
33
|
-
@server1b = Capybara::Server.new(@app1)
|
34
|
-
@server2a = Capybara::Server.new(@app2)
|
35
|
-
@server2b = Capybara::Server.new(@app2)
|
32
|
+
@server1a = Capybara::Server.new(@app1).boot
|
33
|
+
@server1b = Capybara::Server.new(@app1).boot
|
34
|
+
@server2a = Capybara::Server.new(@app2).boot
|
35
|
+
@server2b = Capybara::Server.new(@app2).boot
|
36
36
|
|
37
37
|
@res1 = Net::HTTP.start(@server1b.host, @server1b.port) { |http| http.get('/') }
|
38
38
|
@res1.body.should include('Hello Server')
|
@@ -2,7 +2,7 @@ require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
|
2
2
|
|
3
3
|
if RUBY_PLATFORM =~ /java/
|
4
4
|
describe Capybara::Driver::Celerity do
|
5
|
-
before do
|
5
|
+
before(:all) do
|
6
6
|
@session = Capybara::Session.new(:celerity, TestApp)
|
7
7
|
end
|
8
8
|
|
@@ -24,4 +24,4 @@ if RUBY_PLATFORM =~ /java/
|
|
24
24
|
end
|
25
25
|
else
|
26
26
|
puts "#{File.basename(__FILE__)} requires JRuby; skipping.."
|
27
|
-
end
|
27
|
+
end
|
data/spec/session_spec.rb
CHANGED
@@ -46,13 +46,20 @@ shared_examples_for "session" do
|
|
46
46
|
it_should_behave_like "find_button"
|
47
47
|
it_should_behave_like "find_field"
|
48
48
|
it_should_behave_like "find_link"
|
49
|
+
it_should_behave_like "find_by_id"
|
49
50
|
it_should_behave_like "find"
|
50
51
|
it_should_behave_like "has_content"
|
51
52
|
it_should_behave_like "has_css"
|
52
53
|
it_should_behave_like "has_css"
|
53
54
|
it_should_behave_like "has_xpath"
|
55
|
+
it_should_behave_like "has_link"
|
56
|
+
it_should_behave_like "has_button"
|
57
|
+
it_should_behave_like "has_field"
|
58
|
+
it_should_behave_like "has_select"
|
59
|
+
it_should_behave_like "has_table"
|
54
60
|
it_should_behave_like "select"
|
55
61
|
it_should_behave_like "uncheck"
|
62
|
+
it_should_behave_like "unselect"
|
56
63
|
it_should_behave_like "locate"
|
57
64
|
it_should_behave_like "within"
|
58
65
|
it_should_behave_like "current_url"
|
@@ -3,163 +3,182 @@ require File.expand_path('spec_helper', File.dirname(__FILE__))
|
|
3
3
|
require 'nokogiri'
|
4
4
|
|
5
5
|
shared_examples_for "session with javascript support" do
|
6
|
-
describe '
|
7
|
-
|
8
|
-
|
9
|
-
@session.body.should include('I changed it')
|
10
|
-
@session.body.should_not include('This is text')
|
6
|
+
describe 'all JS specs' do
|
7
|
+
before do
|
8
|
+
Capybara.default_wait_time = 1
|
11
9
|
end
|
12
|
-
end
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
after do
|
12
|
+
Capybara.default_wait_time = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#find' do
|
16
|
+
it "should allow triggering of custom JS events" do
|
17
|
+
pending "cannot figure out how to do this with selenium" if @session.mode == :selenium
|
18
|
+
@session.visit('/with_js')
|
19
|
+
@session.find(:css, '#with_focus_event').trigger(:focus)
|
20
|
+
@session.should have_css('#focus_event_triggered')
|
21
|
+
end
|
20
22
|
end
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
describe '#body' do
|
25
|
+
it "should return the current state of the page" do
|
26
|
+
@session.visit('/with_js')
|
27
|
+
@session.body.should include('I changed it')
|
28
|
+
@session.body.should_not include('This is text')
|
29
|
+
end
|
27
30
|
end
|
28
|
-
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
describe '#source' do
|
33
|
+
it "should return the original, unmodified source of the page" do
|
34
|
+
pending "cannot figure out how to do this with selenium" if @session.mode == :selenium
|
35
|
+
@session.visit('/with_js')
|
36
|
+
@session.source.should include('This is text')
|
37
|
+
@session.source.should_not include('I changed it')
|
38
|
+
end
|
35
39
|
end
|
36
|
-
end
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
describe "#evaluate_script" do
|
42
|
+
it "should return the evaluated script" do
|
43
|
+
@session.visit('/with_js')
|
44
|
+
@session.evaluate_script("1+3").should == 4
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
|
-
|
44
|
-
|
48
|
+
describe '#locate' do
|
49
|
+
it "should wait for asynchronous load" do
|
50
|
+
@session.visit('/with_js')
|
51
|
+
@session.click_link('Click me')
|
52
|
+
@session.locate("//a[contains(.,'Has been clicked')]")[:href].should == '#'
|
53
|
+
end
|
45
54
|
end
|
46
55
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
56
|
+
describe '#wait_until' do
|
57
|
+
before do
|
58
|
+
@default_timeout = Capybara.default_wait_time
|
59
|
+
end
|
60
|
+
|
61
|
+
after do
|
62
|
+
Capybara.default_wait_time = @default_wait_time
|
53
63
|
end
|
54
|
-
@session.evaluate_script('activeRequests == 0').should be_true
|
55
|
-
end
|
56
64
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
@session.
|
61
|
-
|
65
|
+
it "should wait for block to return true" do
|
66
|
+
@session.visit('/with_js')
|
67
|
+
@session.select('My Waiting Option', :from => 'waiter')
|
68
|
+
@session.evaluate_script('activeRequests == 1').should be_true
|
69
|
+
@session.wait_until do
|
70
|
+
@session.evaluate_script('activeRequests == 0')
|
62
71
|
end
|
63
|
-
|
64
|
-
|
72
|
+
@session.evaluate_script('activeRequests == 0').should be_true
|
73
|
+
end
|
65
74
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
it "should raise Capybara::TimeoutError if block doesn't return true within timeout" do
|
76
|
+
@session.visit('/with_html')
|
77
|
+
Proc.new do
|
78
|
+
@session.wait_until(0.1) do
|
79
|
+
@session.find('//div[@id="nosuchthing"]')
|
80
|
+
end
|
81
|
+
end.should raise_error(::Capybara::TimeoutError)
|
82
|
+
end
|
74
83
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
84
|
+
it "should accept custom timeout in seconds" do
|
85
|
+
start = Time.now
|
86
|
+
Capybara.default_wait_time = 5
|
87
|
+
begin
|
88
|
+
@session.wait_until(0.1) { false }
|
89
|
+
rescue Capybara::TimeoutError; end
|
90
|
+
(Time.now - start).should be_close(0.1, 0.1)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should default to Capybara.default_wait_time before timeout" do
|
94
|
+
start = Time.now
|
95
|
+
Capybara.default_wait_time = 0.2
|
96
|
+
begin
|
97
|
+
@session.wait_until { false }
|
98
|
+
rescue Capybara::TimeoutError; end
|
99
|
+
(Time.now - start).should be_close(0.2, 0.1)
|
100
|
+
end
|
82
101
|
end
|
83
|
-
end
|
84
102
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
103
|
+
describe '#click' do
|
104
|
+
it "should wait for asynchronous load" do
|
105
|
+
@session.visit('/with_js')
|
106
|
+
@session.click_link('Click me')
|
107
|
+
@session.click('Has been clicked')
|
108
|
+
end
|
90
109
|
end
|
91
|
-
end
|
92
110
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
111
|
+
describe '#click_link' do
|
112
|
+
it "should wait for asynchronous load" do
|
113
|
+
@session.visit('/with_js')
|
114
|
+
@session.click_link('Click me')
|
115
|
+
@session.click_link('Has been clicked')
|
116
|
+
end
|
98
117
|
end
|
99
|
-
end
|
100
118
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
119
|
+
describe '#click_button' do
|
120
|
+
it "should wait for asynchronous load" do
|
121
|
+
@session.visit('/with_js')
|
122
|
+
@session.click_link('Click me')
|
123
|
+
@session.click_button('New Here')
|
124
|
+
end
|
106
125
|
end
|
107
|
-
end
|
108
126
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
127
|
+
describe '#fill_in' do
|
128
|
+
it "should wait for asynchronous load" do
|
129
|
+
@session.visit('/with_js')
|
130
|
+
@session.click_link('Click me')
|
131
|
+
@session.fill_in('new_field', :with => 'Testing...')
|
132
|
+
end
|
114
133
|
end
|
115
|
-
end
|
116
134
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
135
|
+
describe '#has_xpath?' do
|
136
|
+
it "should wait for content to appear" do
|
137
|
+
@session.visit('/with_js')
|
138
|
+
@session.click_link('Click me')
|
139
|
+
@session.should have_xpath("//input[@type='submit' and @value='New Here']")
|
140
|
+
end
|
122
141
|
end
|
123
|
-
end
|
124
142
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
143
|
+
describe '#has_no_xpath?' do
|
144
|
+
it "should wait for content to disappear" do
|
145
|
+
@session.visit('/with_js')
|
146
|
+
@session.click_link('Click me')
|
147
|
+
@session.should have_no_xpath("//p[@id='change']")
|
148
|
+
end
|
130
149
|
end
|
131
|
-
end
|
132
150
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
151
|
+
describe '#has_css?' do
|
152
|
+
it "should wait for content to appear" do
|
153
|
+
@session.visit('/with_js')
|
154
|
+
@session.click_link('Click me')
|
155
|
+
@session.should have_css("input[type='submit'][value='New Here']")
|
156
|
+
end
|
138
157
|
end
|
139
|
-
end
|
140
158
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
159
|
+
describe '#has_no_xpath?' do
|
160
|
+
it "should wait for content to disappear" do
|
161
|
+
@session.visit('/with_js')
|
162
|
+
@session.click_link('Click me')
|
163
|
+
@session.should have_no_css("p#change")
|
164
|
+
end
|
146
165
|
end
|
147
|
-
end
|
148
166
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
167
|
+
describe '#has_content?' do
|
168
|
+
it "should wait for content to appear" do
|
169
|
+
@session.visit('/with_js')
|
170
|
+
@session.click_link('Click me')
|
171
|
+
@session.should have_content("Has been clicked")
|
172
|
+
end
|
154
173
|
end
|
155
|
-
end
|
156
174
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
175
|
+
describe '#has_no_content?' do
|
176
|
+
it "should wait for content to disappear" do
|
177
|
+
@session.visit('/with_js')
|
178
|
+
@session.click_link('Click me')
|
179
|
+
@session.should have_no_content("I changed it")
|
180
|
+
end
|
162
181
|
end
|
163
|
-
end
|
164
182
|
|
183
|
+
end
|
165
184
|
end
|