capybara 3.3.1 → 3.4.0
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.
- 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
@@ -3,19 +3,19 @@
|
|
3
3
|
Capybara::SpecHelper.spec '#has_select?' do
|
4
4
|
before { @session.visit('/form') }
|
5
5
|
|
6
|
-
it
|
6
|
+
it 'should be true if the field is on the page' do
|
7
7
|
expect(@session).to have_select('Locale')
|
8
8
|
expect(@session).to have_select('form_region')
|
9
9
|
expect(@session).to have_select('Languages')
|
10
10
|
expect(@session).to have_select(:Languages)
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it 'should be false if the field is not on the page' do
|
14
14
|
expect(@session).not_to have_select('Monkey')
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'with selected value' do
|
18
|
-
it
|
18
|
+
it 'should be true if a field with the given value is on the page' do
|
19
19
|
expect(@session).to have_select('form_locale', selected: 'English')
|
20
20
|
expect(@session).to have_select('Region', selected: 'Norway')
|
21
21
|
expect(@session).to have_select('Underwear', selected: [
|
@@ -23,7 +23,7 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
23
23
|
])
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should be false if the given field is not on the page' do
|
27
27
|
expect(@session).not_to have_select('Locale', selected: 'Swedish')
|
28
28
|
expect(@session).not_to have_select('Does not exist', selected: 'John')
|
29
29
|
expect(@session).not_to have_select('City', selected: 'Not there')
|
@@ -38,24 +38,24 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
38
38
|
])
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it 'should be true after the given value is selected' do
|
42
42
|
@session.select('Swedish', from: 'Locale')
|
43
43
|
expect(@session).to have_select('Locale', selected: 'Swedish')
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it 'should be false after a different value is selected' do
|
47
47
|
@session.select('Swedish', from: 'Locale')
|
48
48
|
expect(@session).not_to have_select('Locale', selected: 'English')
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
51
|
+
it 'should be true after the given values are selected' do
|
52
52
|
@session.select('Boxers', from: 'Underwear')
|
53
53
|
expect(@session).to have_select('Underwear', selected: [
|
54
54
|
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
55
55
|
])
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
58
|
+
it 'should be false after one of the values is unselected' do
|
59
59
|
@session.unselect('Briefs', from: 'Underwear')
|
60
60
|
expect(@session).not_to have_select('Underwear', selected: [
|
61
61
|
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
@@ -69,20 +69,20 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
context 'with partial select' do
|
72
|
-
it
|
72
|
+
it 'should be true if a field with the given partial values is on the page' do
|
73
73
|
expect(@session).to have_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'should be false if a field with the given partial values is not on the page' do
|
77
77
|
expect(@session).not_to have_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
80
|
+
it 'should be true after the given partial value is selected' do
|
81
81
|
@session.select('Boxers', from: 'Underwear')
|
82
82
|
expect(@session).to have_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it 'should be false after one of the given partial values is unselected' do
|
86
86
|
@session.unselect('Briefs', from: 'Underwear')
|
87
87
|
expect(@session).not_to have_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
|
88
88
|
end
|
@@ -92,19 +92,19 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
92
92
|
expect(@session).to have_select('Cake', with_selected: ['Chocolate Cake', 'Sponge Cake'])
|
93
93
|
end
|
94
94
|
|
95
|
-
it
|
95
|
+
it 'should support non array partial values' do
|
96
96
|
expect(@session).to have_select('Underwear', with_selected: 'Briefs')
|
97
97
|
expect(@session).not_to have_select('Underwear', with_selected: 'Boxers')
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
context 'with exact options' do
|
102
|
-
it
|
102
|
+
it 'should be true if a field with the given options is on the page' do
|
103
103
|
expect(@session).to have_select('Region', options: %w[Norway Sweden Finland])
|
104
104
|
expect(@session).to have_select('Tendency', options: [])
|
105
105
|
end
|
106
106
|
|
107
|
-
it
|
107
|
+
it 'should be false if the given field is not on the page' do
|
108
108
|
expect(@session).not_to have_select('Locale', options: ['Swedish'])
|
109
109
|
expect(@session).not_to have_select('Does not exist', options: ['John'])
|
110
110
|
expect(@session).not_to have_select('City', options: ['London', 'Made up city'])
|
@@ -112,46 +112,46 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
112
112
|
expect(@session).not_to have_select('Region', options: %w[Norway Norway Norway])
|
113
113
|
end
|
114
114
|
|
115
|
-
it
|
116
|
-
expect(@session).to have_select(
|
115
|
+
it 'should be true even when the options are invisible, if the select itself is invisible' do
|
116
|
+
expect(@session).to have_select('Icecream', visible: false, options: %w[Chocolate Vanilla Strawberry])
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
context 'with partial options' do
|
121
|
-
it
|
121
|
+
it 'should be true if a field with the given partial options is on the page' do
|
122
122
|
expect(@session).to have_select('Region', with_options: %w[Norway Sweden])
|
123
123
|
expect(@session).to have_select('City', with_options: ['London'])
|
124
124
|
end
|
125
125
|
|
126
|
-
it
|
126
|
+
it 'should be false if a field with the given partial options is not on the page' do
|
127
127
|
expect(@session).not_to have_select('Locale', with_options: ['Uruguayan'])
|
128
128
|
expect(@session).not_to have_select('Does not exist', with_options: ['John'])
|
129
129
|
expect(@session).not_to have_select('Region', with_options: %w[Norway Sweden Finland Latvia])
|
130
130
|
end
|
131
131
|
|
132
|
-
it
|
133
|
-
expect(@session).to have_select(
|
132
|
+
it 'should be true even when the options are invisible, if the select itself is invisible' do
|
133
|
+
expect(@session).to have_select('Icecream', visible: false, with_options: %w[Vanilla Strawberry])
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
137
|
context 'with multiple option' do
|
138
|
-
it
|
138
|
+
it 'should find multiple selects if true' do
|
139
139
|
expect(@session).to have_select('form_languages', multiple: true)
|
140
140
|
expect(@session).not_to have_select('form_other_title', multiple: true)
|
141
141
|
end
|
142
142
|
|
143
|
-
it
|
143
|
+
it 'should not find multiple selects if false' do
|
144
144
|
expect(@session).not_to have_select('form_languages', multiple: false)
|
145
145
|
expect(@session).to have_select('form_other_title', multiple: false)
|
146
146
|
end
|
147
147
|
|
148
|
-
it
|
148
|
+
it 'should find both if not specified' do
|
149
149
|
expect(@session).to have_select('form_languages')
|
150
150
|
expect(@session).to have_select('form_other_title')
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
it
|
154
|
+
it 'should support locator-less usage' do
|
155
155
|
expect(@session.has_select?(with_options: %w[Norway Sweden])).to eq true
|
156
156
|
expect(@session).to have_select(with_options: ['London'])
|
157
157
|
expect(@session.has_select?(with_selected: %w[Commando Boxerbriefs])).to eq true
|
@@ -162,18 +162,18 @@ end
|
|
162
162
|
Capybara::SpecHelper.spec '#has_no_select?' do
|
163
163
|
before { @session.visit('/form') }
|
164
164
|
|
165
|
-
it
|
165
|
+
it 'should be false if the field is on the page' do
|
166
166
|
expect(@session).not_to have_no_select('Locale')
|
167
167
|
expect(@session).not_to have_no_select('form_region')
|
168
168
|
expect(@session).not_to have_no_select('Languages')
|
169
169
|
end
|
170
170
|
|
171
|
-
it
|
171
|
+
it 'should be true if the field is not on the page' do
|
172
172
|
expect(@session).to have_no_select('Monkey')
|
173
173
|
end
|
174
174
|
|
175
175
|
context 'with selected value' do
|
176
|
-
it
|
176
|
+
it 'should be false if a field with the given value is on the page' do
|
177
177
|
expect(@session).not_to have_no_select('form_locale', selected: 'English')
|
178
178
|
expect(@session).not_to have_no_select('Region', selected: 'Norway')
|
179
179
|
expect(@session).not_to have_no_select('Underwear', selected: [
|
@@ -181,7 +181,7 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
181
181
|
])
|
182
182
|
end
|
183
183
|
|
184
|
-
it
|
184
|
+
it 'should be true if the given field is not on the page' do
|
185
185
|
expect(@session).to have_no_select('Locale', selected: 'Swedish')
|
186
186
|
expect(@session).to have_no_select('Does not exist', selected: 'John')
|
187
187
|
expect(@session).to have_no_select('City', selected: 'Not there')
|
@@ -196,24 +196,24 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
196
196
|
])
|
197
197
|
end
|
198
198
|
|
199
|
-
it
|
199
|
+
it 'should be false after the given value is selected' do
|
200
200
|
@session.select('Swedish', from: 'Locale')
|
201
201
|
expect(@session).not_to have_no_select('Locale', selected: 'Swedish')
|
202
202
|
end
|
203
203
|
|
204
|
-
it
|
204
|
+
it 'should be true after a different value is selected' do
|
205
205
|
@session.select('Swedish', from: 'Locale')
|
206
206
|
expect(@session).to have_no_select('Locale', selected: 'English')
|
207
207
|
end
|
208
208
|
|
209
|
-
it
|
209
|
+
it 'should be false after the given values are selected' do
|
210
210
|
@session.select('Boxers', from: 'Underwear')
|
211
211
|
expect(@session).not_to have_no_select('Underwear', selected: [
|
212
212
|
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
213
213
|
])
|
214
214
|
end
|
215
215
|
|
216
|
-
it
|
216
|
+
it 'should be true after one of the values is unselected' do
|
217
217
|
@session.unselect('Briefs', from: 'Underwear')
|
218
218
|
expect(@session).to have_no_select('Underwear', selected: [
|
219
219
|
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
@@ -222,36 +222,36 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
222
222
|
end
|
223
223
|
|
224
224
|
context 'with partial select' do
|
225
|
-
it
|
225
|
+
it 'should be false if a field with the given partial values is on the page' do
|
226
226
|
expect(@session).not_to have_no_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
|
227
227
|
end
|
228
228
|
|
229
|
-
it
|
229
|
+
it 'should be true if a field with the given partial values is not on the page' do
|
230
230
|
expect(@session).to have_no_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
|
231
231
|
end
|
232
232
|
|
233
|
-
it
|
233
|
+
it 'should be false after the given partial value is selected' do
|
234
234
|
@session.select('Boxers', from: 'Underwear')
|
235
235
|
expect(@session).not_to have_no_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
|
236
236
|
end
|
237
237
|
|
238
|
-
it
|
238
|
+
it 'should be true after one of the given partial values is unselected' do
|
239
239
|
@session.unselect('Briefs', from: 'Underwear')
|
240
240
|
expect(@session).to have_no_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
|
241
241
|
end
|
242
242
|
|
243
|
-
it
|
243
|
+
it 'should support non array partial values' do
|
244
244
|
expect(@session).not_to have_no_select('Underwear', with_selected: 'Briefs')
|
245
245
|
expect(@session).to have_no_select('Underwear', with_selected: 'Boxers')
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
249
249
|
context 'with exact options' do
|
250
|
-
it
|
250
|
+
it 'should be false if a field with the given options is on the page' do
|
251
251
|
expect(@session).not_to have_no_select('Region', options: %w[Norway Sweden Finland])
|
252
252
|
end
|
253
253
|
|
254
|
-
it
|
254
|
+
it 'should be true if the given field is not on the page' do
|
255
255
|
expect(@session).to have_no_select('Locale', options: ['Swedish'])
|
256
256
|
expect(@session).to have_no_select('Does not exist', options: ['John'])
|
257
257
|
expect(@session).to have_no_select('City', options: ['London', 'Made up city'])
|
@@ -261,19 +261,19 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
261
261
|
end
|
262
262
|
|
263
263
|
context 'with partial options' do
|
264
|
-
it
|
264
|
+
it 'should be false if a field with the given partial options is on the page' do
|
265
265
|
expect(@session).not_to have_no_select('Region', with_options: %w[Norway Sweden])
|
266
266
|
expect(@session).not_to have_no_select('City', with_options: ['London'])
|
267
267
|
end
|
268
268
|
|
269
|
-
it
|
269
|
+
it 'should be true if a field with the given partial options is not on the page' do
|
270
270
|
expect(@session).to have_no_select('Locale', with_options: ['Uruguayan'])
|
271
271
|
expect(@session).to have_no_select('Does not exist', with_options: ['John'])
|
272
272
|
expect(@session).to have_no_select('Region', with_options: %w[Norway Sweden Finland Latvia])
|
273
273
|
end
|
274
274
|
end
|
275
275
|
|
276
|
-
it
|
276
|
+
it 'should support locator-less usage' do
|
277
277
|
expect(@session.has_no_select?(with_options: %w[Norway Sweden Finland Latvia])).to eq true
|
278
278
|
expect(@session).to have_no_select(with_options: ['New London'])
|
279
279
|
expect(@session.has_no_select?(with_selected: ['Boxers'])).to eq true
|
@@ -5,104 +5,104 @@ Capybara::SpecHelper.spec '#has_selector?' do
|
|
5
5
|
@session.visit('/with_html')
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
expect(@session).to have_selector(:xpath,
|
10
|
-
expect(@session).to have_selector(:css,
|
8
|
+
it 'should be true if the given selector is on the page' do
|
9
|
+
expect(@session).to have_selector(:xpath, '//p')
|
10
|
+
expect(@session).to have_selector(:css, 'p a#foo')
|
11
11
|
expect(@session).to have_selector("//p[contains(.,'est')]")
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
15
|
-
expect(@session).not_to have_selector(:xpath,
|
16
|
-
expect(@session).not_to have_selector(:css,
|
14
|
+
it 'should be false if the given selector is not on the page' do
|
15
|
+
expect(@session).not_to have_selector(:xpath, '//abbr')
|
16
|
+
expect(@session).not_to have_selector(:css, 'p a#doesnotexist')
|
17
17
|
expect(@session).not_to have_selector("//p[contains(.,'thisstringisnotonpage')]")
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'should use default selector' do
|
21
21
|
Capybara.default_selector = :css
|
22
|
-
expect(@session).not_to have_selector(
|
23
|
-
expect(@session).to have_selector(
|
22
|
+
expect(@session).not_to have_selector('p a#doesnotexist')
|
23
|
+
expect(@session).to have_selector('p a#foo')
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should respect scopes' do
|
27
27
|
@session.within "//p[@id='first']" do
|
28
28
|
expect(@session).to have_selector(".//a[@id='foo']")
|
29
29
|
expect(@session).not_to have_selector(".//a[@id='red']")
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
34
|
-
expect(@session).to have_selector(:css,
|
33
|
+
it 'should accept a filter block' do
|
34
|
+
expect(@session).to have_selector(:css, 'a', count: 1) { |el| el[:id] == 'foo' }
|
35
35
|
end
|
36
36
|
|
37
|
-
context
|
38
|
-
it
|
39
|
-
expect(@session).to have_selector(
|
37
|
+
context 'with count' do
|
38
|
+
it 'should be true if the content is on the page the given number of times' do
|
39
|
+
expect(@session).to have_selector('//p', count: 3)
|
40
40
|
expect(@session).to have_selector("//p//a[@id='foo']", count: 1)
|
41
41
|
expect(@session).to have_selector("//p[contains(.,'est')]", count: 1)
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
expect(@session).not_to have_selector(
|
44
|
+
it 'should be false if the content is on the page the given number of times' do
|
45
|
+
expect(@session).not_to have_selector('//p', count: 6)
|
46
46
|
expect(@session).not_to have_selector("//p//a[@id='foo']", count: 2)
|
47
47
|
expect(@session).not_to have_selector("//p[contains(.,'est')]", count: 5)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should be false if the content isn't on the page at all" do
|
51
|
-
expect(@session).not_to have_selector(
|
51
|
+
expect(@session).not_to have_selector('//abbr', count: 2)
|
52
52
|
expect(@session).not_to have_selector("//p//a[@id='doesnotexist']", count: 1)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
context
|
57
|
-
it
|
58
|
-
expect(@session).to have_selector(
|
59
|
-
expect(@session).not_to have_selector(
|
56
|
+
context 'with text' do
|
57
|
+
it 'should discard all matches where the given string is not contained' do
|
58
|
+
expect(@session).to have_selector('//p//a', text: 'Redirect', count: 1)
|
59
|
+
expect(@session).not_to have_selector('//p', text: 'Doesnotexist')
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
expect(@session).to have_selector(:id,
|
64
|
-
expect(@session).not_to have_selector(:id,
|
62
|
+
it 'should respect visibility setting' do
|
63
|
+
expect(@session).to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: false)
|
64
|
+
expect(@session).not_to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: true)
|
65
65
|
Capybara.ignore_hidden_elements = false
|
66
|
-
expect(@session).to have_selector(:id,
|
66
|
+
expect(@session).to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: false)
|
67
67
|
Capybara.visible_text_only = true
|
68
|
-
expect(@session).not_to have_selector(:id,
|
68
|
+
expect(@session).not_to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: true)
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
72
|
-
expect(@session).to have_selector(
|
73
|
-
expect(@session).not_to have_selector(
|
71
|
+
it 'should discard all matches where the given regexp is not matched' do
|
72
|
+
expect(@session).to have_selector('//p//a', text: /re[dab]i/i, count: 1)
|
73
|
+
expect(@session).not_to have_selector('//p//a', text: /Red$/)
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'should raise when extra parameters passed' do
|
77
77
|
expect do
|
78
|
-
expect(@session).to have_selector(:css,
|
78
|
+
expect(@session).to have_selector(:css, 'p a#foo', 'extra')
|
79
79
|
end.to raise_error ArgumentError, /extra/
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
context
|
84
|
-
context
|
85
|
-
it
|
86
|
-
expect(@session).to have_selector(:id,
|
87
|
-
expect(@session).to have_no_selector(:id,
|
83
|
+
context 'with exact_text' do
|
84
|
+
context 'string' do
|
85
|
+
it 'should only match elements that match exactly' do
|
86
|
+
expect(@session).to have_selector(:id, 'h2one', exact_text: 'Header Class Test One')
|
87
|
+
expect(@session).to have_no_selector(:id, 'h2one', exact_text: 'Header Class Test')
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
context
|
92
|
-
it
|
93
|
-
expect(@session).to have_selector(:id,
|
94
|
-
expect(@session).to have_no_selector(:id,
|
91
|
+
context 'boolean' do
|
92
|
+
it 'should only match elements that match exactly when true' do
|
93
|
+
expect(@session).to have_selector(:id, 'h2one', text: 'Header Class Test One', exact_text: true)
|
94
|
+
expect(@session).to have_no_selector(:id, 'h2one', text: 'Header Class Test', exact_text: true)
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
98
|
-
expect(@session).to have_selector(:id,
|
99
|
-
expect(@session).to have_selector(:id,
|
97
|
+
it 'should match substrings when false' do
|
98
|
+
expect(@session).to have_selector(:id, 'h2one', text: 'Header Class Test One', exact_text: false)
|
99
|
+
expect(@session).to have_selector(:id, 'h2one', text: 'Header Class Test', exact_text: false)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
context
|
105
|
-
it
|
104
|
+
context 'datalist' do
|
105
|
+
it 'should match options' do
|
106
106
|
@session.visit('/form')
|
107
107
|
expect(@session).to have_selector(:datalist_input, with_options: %w[Jaguar Audi Mercedes])
|
108
108
|
expect(@session).not_to have_selector(:datalist_input, with_options: %w[Ford Chevy])
|
@@ -115,63 +115,63 @@ Capybara::SpecHelper.spec '#has_no_selector?' do
|
|
115
115
|
@session.visit('/with_html')
|
116
116
|
end
|
117
117
|
|
118
|
-
it
|
119
|
-
expect(@session).not_to have_no_selector(:xpath,
|
120
|
-
expect(@session).not_to have_no_selector(:css,
|
118
|
+
it 'should be false if the given selector is on the page' do
|
119
|
+
expect(@session).not_to have_no_selector(:xpath, '//p')
|
120
|
+
expect(@session).not_to have_no_selector(:css, 'p a#foo')
|
121
121
|
expect(@session).not_to have_no_selector("//p[contains(.,'est')]")
|
122
122
|
end
|
123
123
|
|
124
|
-
it
|
125
|
-
expect(@session).to have_no_selector(:xpath,
|
126
|
-
expect(@session).to have_no_selector(:css,
|
124
|
+
it 'should be true if the given selector is not on the page' do
|
125
|
+
expect(@session).to have_no_selector(:xpath, '//abbr')
|
126
|
+
expect(@session).to have_no_selector(:css, 'p a#doesnotexist')
|
127
127
|
expect(@session).to have_no_selector("//p[contains(.,'thisstringisnotonpage')]")
|
128
128
|
end
|
129
129
|
|
130
|
-
it
|
130
|
+
it 'should use default selector' do
|
131
131
|
Capybara.default_selector = :css
|
132
|
-
expect(@session).to have_no_selector(
|
133
|
-
expect(@session).not_to have_no_selector(
|
132
|
+
expect(@session).to have_no_selector('p a#doesnotexist')
|
133
|
+
expect(@session).not_to have_no_selector('p a#foo')
|
134
134
|
end
|
135
135
|
|
136
|
-
it
|
136
|
+
it 'should respect scopes' do
|
137
137
|
@session.within "//p[@id='first']" do
|
138
138
|
expect(@session).not_to have_no_selector(".//a[@id='foo']")
|
139
139
|
expect(@session).to have_no_selector(".//a[@id='red']")
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
it
|
144
|
-
expect(@session).to have_no_selector(:css,
|
143
|
+
it 'should accept a filter block' do
|
144
|
+
expect(@session).to have_no_selector(:css, 'a#foo') { |el| el[:id] != 'foo' }
|
145
145
|
end
|
146
146
|
|
147
|
-
context
|
148
|
-
it
|
149
|
-
expect(@session).not_to have_no_selector(
|
147
|
+
context 'with count' do
|
148
|
+
it 'should be false if the content is on the page the given number of times' do
|
149
|
+
expect(@session).not_to have_no_selector('//p', count: 3)
|
150
150
|
expect(@session).not_to have_no_selector("//p//a[@id='foo']", count: 1)
|
151
151
|
expect(@session).not_to have_no_selector("//p[contains(.,'est')]", count: 1)
|
152
152
|
end
|
153
153
|
|
154
|
-
it
|
155
|
-
expect(@session).to have_no_selector(
|
154
|
+
it 'should be true if the content is on the page the wrong number of times' do
|
155
|
+
expect(@session).to have_no_selector('//p', count: 6)
|
156
156
|
expect(@session).to have_no_selector("//p//a[@id='foo']", count: 2)
|
157
157
|
expect(@session).to have_no_selector("//p[contains(.,'est')]", count: 5)
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should be true if the content isn't on the page at all" do
|
161
|
-
expect(@session).to have_no_selector(
|
161
|
+
expect(@session).to have_no_selector('//abbr', count: 2)
|
162
162
|
expect(@session).to have_no_selector("//p//a[@id='doesnotexist']", count: 1)
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
context
|
167
|
-
it
|
168
|
-
expect(@session).not_to have_no_selector(
|
169
|
-
expect(@session).to have_no_selector(
|
166
|
+
context 'with text' do
|
167
|
+
it 'should discard all matches where the given string is contained' do
|
168
|
+
expect(@session).not_to have_no_selector('//p//a', text: 'Redirect', count: 1)
|
169
|
+
expect(@session).to have_no_selector('//p', text: 'Doesnotexist')
|
170
170
|
end
|
171
171
|
|
172
|
-
it
|
173
|
-
expect(@session).not_to have_no_selector(
|
174
|
-
expect(@session).to have_no_selector(
|
172
|
+
it 'should discard all matches where the given regexp is matched' do
|
173
|
+
expect(@session).not_to have_no_selector('//p//a', text: /re[dab]i/i, count: 1)
|
174
|
+
expect(@session).to have_no_selector('//p//a', text: /Red$/)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|