capybara 3.3.1 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +16 -0
- data/README.md +5 -7
- data/lib/capybara.rb +7 -6
- data/lib/capybara/config.rb +1 -1
- data/lib/capybara/dsl.rb +2 -2
- data/lib/capybara/helpers.rb +3 -3
- data/lib/capybara/minitest/spec.rb +3 -3
- data/lib/capybara/node/actions.rb +18 -18
- data/lib/capybara/node/base.rb +1 -1
- data/lib/capybara/node/element.rb +2 -2
- data/lib/capybara/node/finders.rb +6 -6
- data/lib/capybara/node/matchers.rb +5 -5
- data/lib/capybara/node/simple.rb +2 -2
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/base_query.rb +12 -11
- data/lib/capybara/queries/current_path_query.rb +1 -1
- data/lib/capybara/queries/selector_query.rb +39 -15
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +1 -1
- data/lib/capybara/rack_test/browser.rb +7 -7
- data/lib/capybara/rack_test/driver.rb +1 -1
- data/lib/capybara/rack_test/form.rb +7 -7
- data/lib/capybara/rack_test/node.rb +16 -16
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/result.rb +8 -4
- data/lib/capybara/rspec/features.rb +4 -4
- data/lib/capybara/rspec/matchers.rb +6 -6
- data/lib/capybara/selector.rb +106 -90
- data/lib/capybara/selector/css.rb +4 -4
- data/lib/capybara/selector/filter_set.rb +52 -8
- data/lib/capybara/selector/selector.rb +39 -15
- data/lib/capybara/selenium/driver.rb +10 -10
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +8 -0
- data/lib/capybara/selenium/node.rb +9 -10
- data/lib/capybara/selenium/nodes/chrome_node.rb +18 -0
- data/lib/capybara/selenium/nodes/marionette_node.rb +32 -7
- data/lib/capybara/server.rb +3 -3
- data/lib/capybara/server/animation_disabler.rb +1 -1
- data/lib/capybara/server/middleware.rb +1 -1
- data/lib/capybara/session.rb +23 -19
- data/lib/capybara/session/config.rb +18 -3
- data/lib/capybara/spec/public/test.js +1 -1
- data/lib/capybara/spec/session/accept_alert_spec.rb +10 -10
- data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -3
- data/lib/capybara/spec/session/accept_prompt_spec.rb +9 -10
- data/lib/capybara/spec/session/all_spec.rb +33 -32
- data/lib/capybara/spec/session/ancestor_spec.rb +19 -19
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +38 -38
- data/lib/capybara/spec/session/assert_current_path_spec.rb +16 -16
- data/lib/capybara/spec/session/assert_selector_spec.rb +53 -53
- data/lib/capybara/spec/session/assert_style_spec.rb +3 -3
- data/lib/capybara/spec/session/assert_text_spec.rb +31 -30
- data/lib/capybara/spec/session/assert_title_spec.rb +12 -12
- data/lib/capybara/spec/session/attach_file_spec.rb +51 -52
- data/lib/capybara/spec/session/body_spec.rb +6 -6
- data/lib/capybara/spec/session/check_spec.rb +52 -47
- data/lib/capybara/spec/session/choose_spec.rb +32 -32
- data/lib/capybara/spec/session/click_button_spec.rb +103 -103
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +24 -23
- data/lib/capybara/spec/session/click_link_spec.rb +49 -48
- data/lib/capybara/spec/session/current_scope_spec.rb +7 -7
- data/lib/capybara/spec/session/current_url_spec.rb +26 -27
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +3 -3
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +2 -2
- data/lib/capybara/spec/session/element/assert_match_selector_spec.rb +8 -8
- data/lib/capybara/spec/session/element/match_css_spec.rb +10 -10
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +6 -6
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +51 -51
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +7 -7
- data/lib/capybara/spec/session/evaluate_script_spec.rb +15 -8
- data/lib/capybara/spec/session/execute_script_spec.rb +7 -7
- data/lib/capybara/spec/session/fill_in_spec.rb +43 -42
- data/lib/capybara/spec/session/find_button_spec.rb +23 -23
- data/lib/capybara/spec/session/find_by_id_spec.rb +7 -7
- data/lib/capybara/spec/session/find_field_spec.rb +32 -30
- data/lib/capybara/spec/session/find_link_spec.rb +21 -21
- data/lib/capybara/spec/session/find_spec.rb +153 -135
- data/lib/capybara/spec/session/first_spec.rb +41 -41
- data/lib/capybara/spec/session/frame/frame_title_spec.rb +5 -5
- data/lib/capybara/spec/session/frame/frame_url_spec.rb +5 -5
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +17 -17
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +31 -17
- data/lib/capybara/spec/session/go_back_spec.rb +1 -1
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +17 -17
- data/lib/capybara/spec/session/has_button_spec.rb +13 -13
- data/lib/capybara/spec/session/has_css_spec.rb +133 -131
- data/lib/capybara/spec/session/has_current_path_spec.rb +29 -29
- data/lib/capybara/spec/session/has_field_spec.rb +58 -58
- data/lib/capybara/spec/session/has_link_spec.rb +4 -4
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +24 -24
- data/lib/capybara/spec/session/has_select_spec.rb +43 -43
- data/lib/capybara/spec/session/has_selector_spec.rb +71 -71
- data/lib/capybara/spec/session/has_style_spec.rb +3 -3
- data/lib/capybara/spec/session/has_table_spec.rb +4 -4
- data/lib/capybara/spec/session/has_text_spec.rb +53 -52
- data/lib/capybara/spec/session/has_title_spec.rb +14 -14
- data/lib/capybara/spec/session/has_xpath_spec.rb +39 -38
- data/lib/capybara/spec/session/headers_spec.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +6 -6
- data/lib/capybara/spec/session/node_spec.rb +129 -123
- data/lib/capybara/spec/session/node_wrapper_spec.rb +10 -7
- data/lib/capybara/spec/session/refresh_spec.rb +4 -7
- data/lib/capybara/spec/session/reset_session_spec.rb +28 -28
- data/lib/capybara/spec/session/response_code_spec.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +2 -2
- data/lib/capybara/spec/session/save_page_spec.rb +37 -37
- data/lib/capybara/spec/session/save_screenshot_spec.rb +6 -6
- data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/select_spec.rb +81 -81
- data/lib/capybara/spec/session/selectors_spec.rb +17 -17
- data/lib/capybara/spec/session/sibling_spec.rb +9 -9
- data/lib/capybara/spec/session/text_spec.rb +23 -23
- data/lib/capybara/spec/session/title_spec.rb +5 -5
- data/lib/capybara/spec/session/uncheck_spec.rb +24 -20
- data/lib/capybara/spec/session/unselect_spec.rb +37 -37
- data/lib/capybara/spec/session/visit_spec.rb +48 -49
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -16
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -2
- data/lib/capybara/spec/session/window/window_spec.rb +4 -4
- data/lib/capybara/spec/session/window/within_window_spec.rb +14 -14
- data/lib/capybara/spec/session/within_spec.rb +41 -41
- data/lib/capybara/spec/spec_helper.rb +11 -9
- data/lib/capybara/spec/test_app.rb +18 -17
- data/lib/capybara/spec/views/form.erb +29 -31
- data/lib/capybara/spec/views/with_html.erb +2 -2
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +23 -23
- data/spec/capybara_spec.rb +20 -20
- data/spec/css_splitter_spec.rb +7 -7
- data/spec/dsl_spec.rb +37 -32
- data/spec/filter_set_spec.rb +4 -4
- data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/minitest_spec.rb +4 -4
- data/spec/minitest_spec_spec.rb +23 -23
- data/spec/per_session_config_spec.rb +5 -5
- data/spec/rack_test_spec.rb +44 -44
- data/spec/result_spec.rb +14 -14
- data/spec/rspec/features_spec.rb +13 -13
- data/spec/rspec/scenarios_spec.rb +4 -4
- data/spec/rspec/shared_spec_matchers.rb +282 -281
- data/spec/rspec/views_spec.rb +3 -3
- data/spec/rspec_matchers_spec.rb +10 -10
- data/spec/rspec_spec.rb +29 -29
- data/spec/selector_spec.rb +64 -64
- data/spec/selenium_spec_chrome.rb +14 -22
- data/spec/selenium_spec_chrome_remote.rb +28 -8
- data/spec/selenium_spec_edge.rb +9 -4
- data/spec/selenium_spec_firefox_remote.rb +87 -0
- data/spec/selenium_spec_ie.rb +9 -4
- data/spec/selenium_spec_marionette.rb +42 -18
- data/spec/server_spec.rb +29 -27
- data/spec/session_spec.rb +17 -17
- data/spec/shared_selenium_session.rb +70 -52
- data/spec/spec_helper.rb +1 -1
- metadata +4 -2
@@ -5,19 +5,19 @@ Capybara::SpecHelper.spec '#has_style?', requires: [:css] do
|
|
5
5
|
@session.visit('/with_html')
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should be true if the element has the given style' do
|
9
9
|
expect(@session.find(:css, '#first')).to have_style(display: 'block')
|
10
10
|
expect(@session.find(:css, '#first').has_style?(display: 'block')).to be true
|
11
11
|
expect(@session.find(:css, '#second')).to have_style('display' => 'inline')
|
12
12
|
expect(@session.find(:css, '#second').has_style?('display' => 'inline')).to be true
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'should be false if the element does not have the given style' do
|
16
16
|
expect(@session.find(:css, '#first').has_style?('display' => 'inline')).to be false
|
17
17
|
expect(@session.find(:css, '#second').has_style?(display: 'block')).to be false
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'allows Regexp for value matching' do
|
21
21
|
expect(@session.find(:css, '#first')).to have_style(display: /^bl/)
|
22
22
|
expect(@session.find(:css, '#first').has_style?('display' => /^bl/)).to be true
|
23
23
|
expect(@session.find(:css, '#first').has_style?(display: /^in/)).to be false
|
@@ -5,13 +5,13 @@ Capybara::SpecHelper.spec '#has_table?' do
|
|
5
5
|
@session.visit('/tables')
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should be true if the table is on the page' do
|
9
9
|
expect(@session).to have_table('Villain')
|
10
10
|
expect(@session).to have_table('villain_table')
|
11
11
|
expect(@session).to have_table(:villain_table)
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'should be false if the table is not on the page' do
|
15
15
|
expect(@session).not_to have_table('Monkey')
|
16
16
|
end
|
17
17
|
end
|
@@ -21,12 +21,12 @@ Capybara::SpecHelper.spec '#has_no_table?' do
|
|
21
21
|
@session.visit('/tables')
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'should be false if the table is on the page' do
|
25
25
|
expect(@session).not_to have_no_table('Villain')
|
26
26
|
expect(@session).not_to have_no_table('villain_table')
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'should be true if the table is not on the page' do
|
30
30
|
expect(@session).to have_no_table('Monkey')
|
31
31
|
end
|
32
32
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Capybara::SpecHelper.spec '#has_text?' do
|
4
|
-
it
|
4
|
+
it 'should be true if the given text is on the page at least once' do
|
5
5
|
@session.visit('/with_html')
|
6
6
|
expect(@session).to have_text('est')
|
7
7
|
expect(@session).to have_text('Lorem')
|
@@ -9,32 +9,32 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|
9
9
|
expect(@session).to have_text(:Redirect)
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'should be true if scoped to an element which has the text' do
|
13
13
|
@session.visit('/with_html')
|
14
14
|
@session.within("//a[@title='awesome title']") do
|
15
15
|
expect(@session).to have_text('labore')
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'should be false if scoped to an element which does not have the text' do
|
20
20
|
@session.visit('/with_html')
|
21
21
|
@session.within("//a[@title='awesome title']") do
|
22
22
|
expect(@session).not_to have_text('monkey')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should ignore tags' do
|
27
27
|
@session.visit('/with_html')
|
28
28
|
expect(@session).not_to have_text('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
|
29
29
|
expect(@session).to have_text('exercitation ullamco laboris')
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'should search correctly normalized text' do
|
33
33
|
@session.visit('/with_html')
|
34
34
|
expect(@session).to have_text('text with whitespace')
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it 'should be false if the given text is not on the page' do
|
38
38
|
@session.visit('/with_html')
|
39
39
|
expect(@session).not_to have_text('xxxxyzzz')
|
40
40
|
expect(@session).not_to have_text('monkey')
|
@@ -66,23 +66,23 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|
66
66
|
expect(@session).not_to have_text('aVar')
|
67
67
|
end
|
68
68
|
|
69
|
-
it
|
69
|
+
it 'should be false if the given text is on the page but not visible' do
|
70
70
|
@session.visit('/with_html')
|
71
71
|
expect(@session).not_to have_text('Inside element with hidden ancestor')
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
74
|
+
it 'should be true if :all given and text is invisible.' do
|
75
75
|
@session.visit('/with_html')
|
76
76
|
expect(@session).to have_text(:all, 'Some of this text is hidden!')
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
79
|
+
it 'should be true if `Capybara.ignore_hidden_elements = false` and text is invisible.' do
|
80
80
|
Capybara.ignore_hidden_elements = false
|
81
81
|
@session.visit('/with_html')
|
82
82
|
expect(@session).to have_text('Some of this text is hidden!')
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it 'should be true if the text in the page matches given regexp' do
|
86
86
|
@session.visit('/with_html')
|
87
87
|
expect(@session).to have_text(/Lorem/)
|
88
88
|
end
|
@@ -92,50 +92,50 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|
92
92
|
expect(@session).not_to have_text(/xxxxyzzz/)
|
93
93
|
end
|
94
94
|
|
95
|
-
context
|
96
|
-
it
|
95
|
+
context 'with exact: true option' do
|
96
|
+
it 'should be true if text matches exactly' do
|
97
97
|
@session.visit('/with_html')
|
98
|
-
expect(@session.find(:id,
|
98
|
+
expect(@session.find(:id, 'h2one')).to have_text('Header Class Test One', exact: true)
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should be false if text doesn't match exactly" do
|
102
102
|
@session.visit('/with_html')
|
103
|
-
expect(@session.find(:id,
|
103
|
+
expect(@session.find(:id, 'h2one')).not_to have_text('Header Class Test On', exact: true)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
it
|
107
|
+
it 'should escape any characters that would have special meaning in a regexp' do
|
108
108
|
@session.visit('/with_html')
|
109
109
|
expect(@session).not_to have_text('.orem')
|
110
110
|
end
|
111
111
|
|
112
|
-
it
|
112
|
+
it 'should accept non-string parameters' do
|
113
113
|
@session.visit('/with_html')
|
114
114
|
expect(@session).to have_text(42)
|
115
115
|
end
|
116
116
|
|
117
|
-
it
|
117
|
+
it 'should be true when passed nil' do
|
118
118
|
# nil is converted to '' when to_s is invoked
|
119
119
|
@session.visit('/with_html')
|
120
120
|
expect(@session).to have_text(nil)
|
121
121
|
end
|
122
122
|
|
123
|
-
it
|
123
|
+
it 'should wait for text to appear', requires: [:js] do
|
124
124
|
Capybara.using_wait_time(3) do
|
125
125
|
@session.visit('/with_js')
|
126
126
|
@session.click_link('Click me')
|
127
|
-
expect(@session).to have_text(
|
127
|
+
expect(@session).to have_text('Has been clicked')
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
-
context
|
132
|
-
it
|
131
|
+
context 'with between' do
|
132
|
+
it 'should be true if the text occurs within the range given' do
|
133
133
|
@session.visit('/with_count')
|
134
134
|
expect(@session).to have_text('count', between: 1..3)
|
135
135
|
expect(@session).to have_text(/count/, between: 2..2)
|
136
136
|
end
|
137
137
|
|
138
|
-
it
|
138
|
+
it 'should be false if the text occurs more or fewer times than range' do
|
139
139
|
@session.visit('/with_count')
|
140
140
|
expect(@session).not_to have_text('count', between: 0..1)
|
141
141
|
expect(@session).not_to have_text('count', between: 3..10)
|
@@ -143,76 +143,76 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
context
|
147
|
-
it
|
146
|
+
context 'with count' do
|
147
|
+
it 'should be true if the text occurs the given number of times' do
|
148
148
|
@session.visit('/with_count')
|
149
149
|
expect(@session).to have_text('count', count: 2)
|
150
150
|
end
|
151
151
|
|
152
|
-
it
|
152
|
+
it 'should be false if the text occurs a different number of times than the given' do
|
153
153
|
@session.visit('/with_count')
|
154
154
|
expect(@session).not_to have_text('count', count: 0)
|
155
155
|
expect(@session).not_to have_text('count', count: 1)
|
156
156
|
expect(@session).not_to have_text(/count/, count: 3)
|
157
157
|
end
|
158
158
|
|
159
|
-
it
|
159
|
+
it 'should coerce count to an integer' do
|
160
160
|
@session.visit('/with_count')
|
161
161
|
expect(@session).to have_text('count', count: '2')
|
162
162
|
expect(@session).not_to have_text('count', count: '3')
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
context
|
167
|
-
it
|
166
|
+
context 'with maximum' do
|
167
|
+
it 'should be true when text occurs same or fewer times than given' do
|
168
168
|
@session.visit('/with_count')
|
169
169
|
expect(@session).to have_text('count', maximum: 2)
|
170
170
|
expect(@session).to have_text(/count/, maximum: 3)
|
171
171
|
end
|
172
172
|
|
173
|
-
it
|
173
|
+
it 'should be false when text occurs more times than given' do
|
174
174
|
@session.visit('/with_count')
|
175
175
|
expect(@session).not_to have_text('count', maximum: 1)
|
176
176
|
expect(@session).not_to have_text('count', maximum: 0)
|
177
177
|
end
|
178
178
|
|
179
|
-
it
|
179
|
+
it 'should coerce maximum to an integer' do
|
180
180
|
@session.visit('/with_count')
|
181
181
|
expect(@session).to have_text('count', maximum: '2')
|
182
182
|
expect(@session).not_to have_text('count', maximum: '1')
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
context
|
187
|
-
it
|
186
|
+
context 'with minimum' do
|
187
|
+
it 'should be true when text occurs same or more times than given' do
|
188
188
|
@session.visit('/with_count')
|
189
189
|
expect(@session).to have_text('count', minimum: 2)
|
190
190
|
expect(@session).to have_text(/count/, minimum: 0)
|
191
191
|
end
|
192
192
|
|
193
|
-
it
|
193
|
+
it 'should be false when text occurs fewer times than given' do
|
194
194
|
@session.visit('/with_count')
|
195
195
|
expect(@session).not_to have_text('count', minimum: 3)
|
196
196
|
end
|
197
197
|
|
198
|
-
it
|
198
|
+
it 'should coerce minimum to an integer' do
|
199
199
|
@session.visit('/with_count')
|
200
200
|
expect(@session).to have_text('count', minimum: '2')
|
201
201
|
expect(@session).not_to have_text('count', minimum: '3')
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
context
|
206
|
-
it
|
205
|
+
context 'with wait', requires: [:js] do
|
206
|
+
it 'should find element if it appears before given wait duration' do
|
207
207
|
Capybara.using_wait_time(0.1) do
|
208
208
|
@session.visit('/with_js')
|
209
209
|
@session.click_link('Click me')
|
210
|
-
expect(@session).to have_text('Has been clicked', wait:
|
210
|
+
expect(@session).to have_text('Has been clicked', wait: 2)
|
211
211
|
end
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
-
it
|
215
|
+
it 'should raise an error if an invalid option is passed' do
|
216
216
|
@session.visit('/with_html')
|
217
217
|
expect do
|
218
218
|
expect(@session).to have_text('Lorem', invalid: true)
|
@@ -221,34 +221,34 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|
221
221
|
end
|
222
222
|
|
223
223
|
Capybara::SpecHelper.spec '#has_no_text?' do
|
224
|
-
it
|
224
|
+
it 'should be false if the given text is on the page at least once' do
|
225
225
|
@session.visit('/with_html')
|
226
226
|
expect(@session).not_to have_no_text('est')
|
227
227
|
expect(@session).not_to have_no_text('Lorem')
|
228
228
|
expect(@session).not_to have_no_text('Redirect')
|
229
229
|
end
|
230
230
|
|
231
|
-
it
|
231
|
+
it 'should be false if scoped to an element which has the text' do
|
232
232
|
@session.visit('/with_html')
|
233
233
|
@session.within("//a[@title='awesome title']") do
|
234
234
|
expect(@session).not_to have_no_text('labore')
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
-
it
|
238
|
+
it 'should be true if scoped to an element which does not have the text' do
|
239
239
|
@session.visit('/with_html')
|
240
240
|
@session.within("//a[@title='awesome title']") do
|
241
241
|
expect(@session).to have_no_text('monkey')
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
245
|
-
it
|
245
|
+
it 'should ignore tags' do
|
246
246
|
@session.visit('/with_html')
|
247
247
|
expect(@session).to have_no_text('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
|
248
248
|
expect(@session).not_to have_no_text('exercitation ullamco laboris')
|
249
249
|
end
|
250
250
|
|
251
|
-
it
|
251
|
+
it 'should be true if the given text is not on the page' do
|
252
252
|
@session.visit('/with_html')
|
253
253
|
expect(@session).to have_no_text('xxxxyzzz')
|
254
254
|
expect(@session).to have_no_text('monkey')
|
@@ -280,17 +280,17 @@ Capybara::SpecHelper.spec '#has_no_text?' do
|
|
280
280
|
expect(@session).to have_no_text('aVar')
|
281
281
|
end
|
282
282
|
|
283
|
-
it
|
283
|
+
it 'should be true if the given text is on the page but not visible' do
|
284
284
|
@session.visit('/with_html')
|
285
285
|
expect(@session).to have_no_text('Inside element with hidden ancestor')
|
286
286
|
end
|
287
287
|
|
288
|
-
it
|
288
|
+
it 'should be false if :all given and text is invisible.' do
|
289
289
|
@session.visit('/with_html')
|
290
290
|
expect(@session).not_to have_no_text(:all, 'Some of this text is hidden!')
|
291
291
|
end
|
292
292
|
|
293
|
-
it
|
293
|
+
it 'should be false if `Capybara.ignore_hidden_elements = false` and text is invisible.' do
|
294
294
|
Capybara.ignore_hidden_elements = false
|
295
295
|
@session.visit('/with_html')
|
296
296
|
expect(@session).not_to have_no_text('Some of this text is hidden!')
|
@@ -301,24 +301,25 @@ Capybara::SpecHelper.spec '#has_no_text?' do
|
|
301
301
|
expect(@session).to have_no_text(/xxxxyzzz/)
|
302
302
|
end
|
303
303
|
|
304
|
-
it
|
304
|
+
it 'should be false if the text in the page matches given regexp' do
|
305
305
|
@session.visit('/with_html')
|
306
306
|
expect(@session).not_to have_no_text(/Lorem/)
|
307
307
|
end
|
308
308
|
|
309
|
-
it
|
309
|
+
it 'should escape any characters that would have special meaning in a regexp' do
|
310
310
|
@session.visit('/with_html')
|
311
311
|
expect(@session).to have_no_text('.orem')
|
312
312
|
end
|
313
313
|
|
314
|
-
it
|
314
|
+
it 'should wait for text to disappear', requires: [:js] do
|
315
|
+
Capybara.default_max_wait_time = 2
|
315
316
|
@session.visit('/with_js')
|
316
317
|
@session.click_link('Click me')
|
317
|
-
expect(@session).to have_no_text(
|
318
|
+
expect(@session).to have_no_text('I changed it')
|
318
319
|
end
|
319
320
|
|
320
|
-
context
|
321
|
-
it
|
321
|
+
context 'with wait', requires: [:js] do
|
322
|
+
it 'should not find element if it appears after given wait duration' do
|
322
323
|
@session.visit('/with_js')
|
323
324
|
@session.click_link('Click me')
|
324
325
|
expect(@session).to have_no_text('Has been clicked', wait: 0.05)
|
@@ -5,35 +5,35 @@ Capybara::SpecHelper.spec '#has_title?' do
|
|
5
5
|
@session.visit('/with_js')
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should be true if the page has the given title' do
|
9
9
|
expect(@session).to have_title('with_js')
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'should allow regexp matches' do
|
13
13
|
expect(@session).to have_title(/w[a-z]{3}_js/)
|
14
14
|
expect(@session).not_to have_title(/monkey/)
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
@session.click_link(
|
19
|
-
expect(@session).to have_title(
|
17
|
+
it 'should wait for title', requires: [:js] do
|
18
|
+
@session.click_link('Change title')
|
19
|
+
expect(@session).to have_title('changed title')
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'should be false if the page has not the given title' do
|
23
23
|
expect(@session).not_to have_title('monkey')
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should default to exact: false matching' do
|
27
27
|
expect(@session).to have_title('with_js', exact: false)
|
28
28
|
expect(@session).to have_title('with_', exact: false)
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it 'should match exactly if exact: true option passed' do
|
32
32
|
expect(@session).to have_title('with_js', exact: true)
|
33
33
|
expect(@session).not_to have_title('with_', exact: true)
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should match partial if exact: false option passed' do
|
37
37
|
expect(@session).to have_title('with_js', exact: false)
|
38
38
|
expect(@session).to have_title('with_', exact: false)
|
39
39
|
end
|
@@ -44,23 +44,23 @@ Capybara::SpecHelper.spec '#has_no_title?' do
|
|
44
44
|
@session.visit('/with_js')
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
47
|
+
it 'should be false if the page has the given title' do
|
48
48
|
expect(@session).not_to have_no_title('with_js')
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
51
|
+
it 'should allow regexp matches' do
|
52
52
|
expect(@session).not_to have_no_title(/w[a-z]{3}_js/)
|
53
53
|
expect(@session).to have_no_title(/monkey/)
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it 'should wait for title to disappear', requires: [:js] do
|
57
57
|
Capybara.using_wait_time(5) do
|
58
|
-
@session.click_link(
|
58
|
+
@session.click_link('Change title') # triggers title change after 400ms
|
59
59
|
expect(@session).to have_no_title('with_js')
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
63
|
+
it 'should be true if the page has not the given title' do
|
64
64
|
expect(@session).to have_no_title('monkey')
|
65
65
|
end
|
66
66
|
end
|
@@ -5,31 +5,31 @@ Capybara::SpecHelper.spec '#has_xpath?' do
|
|
5
5
|
@session.visit('/with_html')
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
expect(@session).to have_xpath(
|
8
|
+
it 'should be true if the given selector is on the page' do
|
9
|
+
expect(@session).to have_xpath('//p')
|
10
10
|
expect(@session).to have_xpath("//p//a[@id='foo']")
|
11
11
|
expect(@session).to have_xpath("//p[contains(.,'est')]")
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
15
|
-
expect(@session).not_to have_xpath(
|
14
|
+
it 'should be false if the given selector is not on the page' do
|
15
|
+
expect(@session).not_to have_xpath('//abbr')
|
16
16
|
expect(@session).not_to have_xpath("//p//a[@id='doesnotexist']")
|
17
17
|
expect(@session).not_to have_xpath("//p[contains(.,'thisstringisnotonpage')]")
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'should use xpath even if default selector is CSS' do
|
21
21
|
Capybara.default_selector = :css
|
22
22
|
expect(@session).not_to have_xpath("//p//a[@id='doesnotexist']")
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it 'should respect scopes' do
|
26
26
|
@session.within "//p[@id='first']" do
|
27
27
|
expect(@session).to have_xpath(".//a[@id='foo']")
|
28
28
|
expect(@session).not_to have_xpath(".//a[@id='red']")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'should wait for content to appear', requires: [:js] do
|
33
33
|
Capybara.using_wait_time(3) do
|
34
34
|
@session.visit('/with_js')
|
35
35
|
@session.click_link('Click me') # updates page after 500ms
|
@@ -37,31 +37,31 @@ Capybara::SpecHelper.spec '#has_xpath?' do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
context
|
41
|
-
it
|
42
|
-
expect(@session).to have_xpath(
|
40
|
+
context 'with count' do
|
41
|
+
it 'should be true if the content occurs the given number of times' do
|
42
|
+
expect(@session).to have_xpath('//p', count: 3)
|
43
43
|
expect(@session).to have_xpath("//p//a[@id='foo']", count: 1)
|
44
44
|
expect(@session).to have_xpath("//p[contains(.,'est')]", count: 1)
|
45
45
|
expect(@session).to have_xpath("//p//a[@id='doesnotexist']", count: 0)
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
49
|
-
expect(@session).not_to have_xpath(
|
48
|
+
it 'should be false if the content occurs a different number of times than the given' do
|
49
|
+
expect(@session).not_to have_xpath('//p', count: 6)
|
50
50
|
expect(@session).not_to have_xpath("//p//a[@id='foo']", count: 2)
|
51
51
|
expect(@session).not_to have_xpath("//p[contains(.,'est')]", count: 5)
|
52
52
|
expect(@session).not_to have_xpath("//p//a[@id='doesnotexist']", count: 1)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
context
|
57
|
-
it
|
58
|
-
expect(@session).to have_xpath(
|
59
|
-
expect(@session).not_to have_xpath(
|
56
|
+
context 'with text' do
|
57
|
+
it 'should discard all matches where the given string is not contained' do
|
58
|
+
expect(@session).to have_xpath('//p//a', text: 'Redirect', count: 1)
|
59
|
+
expect(@session).not_to have_xpath('//p', text: 'Doesnotexist')
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
expect(@session).to have_xpath(
|
64
|
-
expect(@session).not_to have_xpath(
|
62
|
+
it 'should discard all matches where the given regexp is not matched' do
|
63
|
+
expect(@session).to have_xpath('//p//a', text: /re[dab]i/i, count: 1)
|
64
|
+
expect(@session).not_to have_xpath('//p//a', text: /Red$/)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -71,61 +71,62 @@ Capybara::SpecHelper.spec '#has_no_xpath?' do
|
|
71
71
|
@session.visit('/with_html')
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
75
|
-
expect(@session).not_to have_no_xpath(
|
74
|
+
it 'should be false if the given selector is on the page' do
|
75
|
+
expect(@session).not_to have_no_xpath('//p')
|
76
76
|
expect(@session).not_to have_no_xpath("//p//a[@id='foo']")
|
77
77
|
expect(@session).not_to have_no_xpath("//p[contains(.,'est')]")
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
expect(@session).to have_no_xpath(
|
80
|
+
it 'should be true if the given selector is not on the page' do
|
81
|
+
expect(@session).to have_no_xpath('//abbr')
|
82
82
|
expect(@session).to have_no_xpath("//p//a[@id='doesnotexist']")
|
83
83
|
expect(@session).to have_no_xpath("//p[contains(.,'thisstringisnotonpage')]")
|
84
84
|
end
|
85
85
|
|
86
|
-
it
|
86
|
+
it 'should use xpath even if default selector is CSS' do
|
87
87
|
Capybara.default_selector = :css
|
88
88
|
expect(@session).to have_no_xpath("//p//a[@id='doesnotexist']")
|
89
89
|
end
|
90
90
|
|
91
|
-
it
|
91
|
+
it 'should respect scopes' do
|
92
92
|
@session.within "//p[@id='first']" do
|
93
93
|
expect(@session).not_to have_no_xpath(".//a[@id='foo']")
|
94
94
|
expect(@session).to have_no_xpath(".//a[@id='red']")
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
it
|
98
|
+
it 'should wait for content to disappear', requires: [:js] do
|
99
|
+
Capybara.default_max_wait_time = 2
|
99
100
|
@session.visit('/with_js')
|
100
101
|
@session.click_link('Click me')
|
101
102
|
expect(@session).to have_no_xpath("//p[@id='change']")
|
102
103
|
end
|
103
104
|
|
104
|
-
context
|
105
|
-
it
|
106
|
-
expect(@session).not_to have_no_xpath(
|
105
|
+
context 'with count' do
|
106
|
+
it 'should be false if the content occurs the given number of times' do
|
107
|
+
expect(@session).not_to have_no_xpath('//p', count: 3)
|
107
108
|
expect(@session).not_to have_no_xpath("//p//a[@id='foo']", count: 1)
|
108
109
|
expect(@session).not_to have_no_xpath("//p[contains(.,'est')]", count: 1)
|
109
110
|
expect(@session).not_to have_no_xpath("//p//a[@id='doesnotexist']", count: 0)
|
110
111
|
end
|
111
112
|
|
112
|
-
it
|
113
|
-
expect(@session).to have_no_xpath(
|
113
|
+
it 'should be true if the content occurs a different number of times than the given' do
|
114
|
+
expect(@session).to have_no_xpath('//p', count: 6)
|
114
115
|
expect(@session).to have_no_xpath("//p//a[@id='foo']", count: 2)
|
115
116
|
expect(@session).to have_no_xpath("//p[contains(.,'est')]", count: 5)
|
116
117
|
expect(@session).to have_no_xpath("//p//a[@id='doesnotexist']", count: 1)
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
120
|
-
context
|
121
|
-
it
|
122
|
-
expect(@session).not_to have_no_xpath(
|
123
|
-
expect(@session).to have_no_xpath(
|
121
|
+
context 'with text' do
|
122
|
+
it 'should discard all matches where the given string is contained' do
|
123
|
+
expect(@session).not_to have_no_xpath('//p//a', text: 'Redirect', count: 1)
|
124
|
+
expect(@session).to have_no_xpath('//p', text: 'Doesnotexist')
|
124
125
|
end
|
125
126
|
|
126
|
-
it
|
127
|
-
expect(@session).not_to have_no_xpath(
|
128
|
-
expect(@session).to have_no_xpath(
|
127
|
+
it 'should discard all matches where the given regexp is matched' do
|
128
|
+
expect(@session).not_to have_no_xpath('//p//a', text: /re[dab]i/i, count: 1)
|
129
|
+
expect(@session).to have_no_xpath('//p//a', text: /Red$/)
|
129
130
|
end
|
130
131
|
end
|
131
132
|
end
|