capybara 3.16.1 → 3.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/History.md +321 -0
- data/README.md +51 -60
- data/lib/capybara.rb +71 -114
- data/lib/capybara/config.rb +8 -5
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/node.rb +15 -3
- data/lib/capybara/dsl.rb +10 -2
- data/lib/capybara/helpers.rb +5 -3
- data/lib/capybara/minitest.rb +242 -141
- data/lib/capybara/minitest/spec.rb +159 -90
- data/lib/capybara/node/actions.rb +85 -74
- data/lib/capybara/node/base.rb +4 -4
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +3 -3
- data/lib/capybara/node/element.rb +216 -117
- data/lib/capybara/node/finders.rb +65 -65
- data/lib/capybara/node/matchers.rb +228 -126
- data/lib/capybara/node/simple.rb +9 -4
- data/lib/capybara/queries/ancestor_query.rb +5 -7
- data/lib/capybara/queries/base_query.rb +2 -1
- data/lib/capybara/queries/current_path_query.rb +1 -1
- data/lib/capybara/queries/selector_query.rb +296 -30
- data/lib/capybara/queries/sibling_query.rb +5 -4
- data/lib/capybara/queries/style_query.rb +2 -2
- data/lib/capybara/queries/text_query.rb +13 -1
- data/lib/capybara/queries/title_query.rb +1 -1
- data/lib/capybara/rack_test/browser.rb +7 -2
- data/lib/capybara/rack_test/driver.rb +1 -1
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/rack_test/node.rb +43 -7
- data/lib/capybara/registration_container.rb +44 -0
- data/lib/capybara/registrations/drivers.rb +36 -0
- data/lib/capybara/registrations/patches/puma_ssl.rb +27 -0
- data/lib/capybara/registrations/servers.rb +44 -0
- data/lib/capybara/result.rb +36 -8
- data/lib/capybara/rspec/matcher_proxies.rb +6 -4
- data/lib/capybara/rspec/matchers.rb +100 -63
- data/lib/capybara/rspec/matchers/base.rb +23 -10
- data/lib/capybara/rspec/matchers/count_sugar.rb +37 -0
- data/lib/capybara/rspec/matchers/have_ancestor.rb +28 -0
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/have_selector.rb +16 -8
- data/lib/capybara/rspec/matchers/have_sibling.rb +27 -0
- data/lib/capybara/rspec/matchers/have_text.rb +4 -4
- data/lib/capybara/rspec/matchers/have_title.rb +2 -2
- data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
- data/lib/capybara/rspec/matchers/match_style.rb +2 -2
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
- data/lib/capybara/selector.rb +219 -588
- data/lib/capybara/selector/builders/css_builder.rb +10 -6
- data/lib/capybara/selector/builders/xpath_builder.rb +1 -1
- data/lib/capybara/selector/css.rb +4 -2
- data/lib/capybara/selector/definition.rb +277 -0
- data/lib/capybara/selector/definition/button.rb +52 -0
- data/lib/capybara/selector/definition/checkbox.rb +26 -0
- data/lib/capybara/selector/definition/css.rb +10 -0
- data/lib/capybara/selector/definition/datalist_input.rb +35 -0
- data/lib/capybara/selector/definition/datalist_option.rb +25 -0
- data/lib/capybara/selector/definition/element.rb +27 -0
- data/lib/capybara/selector/definition/field.rb +40 -0
- data/lib/capybara/selector/definition/fieldset.rb +14 -0
- data/lib/capybara/selector/definition/file_field.rb +13 -0
- data/lib/capybara/selector/definition/fillable_field.rb +33 -0
- data/lib/capybara/selector/definition/frame.rb +17 -0
- data/lib/capybara/selector/definition/id.rb +6 -0
- data/lib/capybara/selector/definition/label.rb +62 -0
- data/lib/capybara/selector/definition/link.rb +54 -0
- data/lib/capybara/selector/definition/link_or_button.rb +16 -0
- data/lib/capybara/selector/definition/option.rb +27 -0
- data/lib/capybara/selector/definition/radio_button.rb +27 -0
- data/lib/capybara/selector/definition/select.rb +81 -0
- data/lib/capybara/selector/definition/table.rb +109 -0
- data/lib/capybara/selector/definition/table_row.rb +21 -0
- data/lib/capybara/selector/definition/xpath.rb +5 -0
- data/lib/capybara/selector/filter_set.rb +13 -9
- data/lib/capybara/selector/filters/base.rb +11 -2
- data/lib/capybara/selector/filters/locator_filter.rb +13 -3
- data/lib/capybara/selector/regexp_disassembler.rb +9 -2
- data/lib/capybara/selector/selector.rb +43 -448
- data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -0
- data/lib/capybara/selenium/atoms/isDisplayed.min.js +1 -0
- data/lib/capybara/selenium/atoms/src/getAttribute.js +161 -0
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +454 -0
- data/lib/capybara/selenium/driver.rb +125 -56
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +73 -17
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +124 -0
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +41 -2
- data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +14 -1
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +14 -5
- data/lib/capybara/selenium/extensions/file_input_click_emulation.rb +34 -0
- data/lib/capybara/selenium/extensions/find.rb +67 -45
- data/lib/capybara/selenium/extensions/html5_drag.rb +152 -36
- data/lib/capybara/selenium/extensions/modifier_keys_stack.rb +28 -0
- data/lib/capybara/selenium/logger_suppressor.rb +34 -0
- data/lib/capybara/selenium/node.rb +227 -56
- data/lib/capybara/selenium/nodes/chrome_node.rb +93 -8
- data/lib/capybara/selenium/nodes/edge_node.rb +104 -0
- data/lib/capybara/selenium/nodes/firefox_node.rb +37 -59
- data/lib/capybara/selenium/nodes/ie_node.rb +22 -0
- data/lib/capybara/selenium/nodes/safari_node.rb +27 -54
- data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
- data/lib/capybara/selenium/patches/atoms.rb +18 -0
- data/lib/capybara/selenium/patches/is_displayed.rb +16 -0
- data/lib/capybara/selenium/patches/logs.rb +45 -0
- data/lib/capybara/server.rb +19 -3
- data/lib/capybara/server/animation_disabler.rb +2 -2
- data/lib/capybara/server/checker.rb +6 -2
- data/lib/capybara/server/middleware.rb +23 -13
- data/lib/capybara/session.rb +124 -106
- data/lib/capybara/session/config.rb +12 -10
- data/lib/capybara/session/matchers.rb +6 -6
- data/lib/capybara/spec/public/offset.js +6 -0
- data/lib/capybara/spec/public/test.js +94 -5
- data/lib/capybara/spec/session/all_spec.rb +84 -6
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_current_path_spec.rb +5 -2
- data/lib/capybara/spec/session/assert_text_spec.rb +9 -5
- data/lib/capybara/spec/session/attach_file_spec.rb +14 -6
- data/lib/capybara/spec/session/check_spec.rb +10 -4
- data/lib/capybara/spec/session/choose_spec.rb +8 -2
- data/lib/capybara/spec/session/click_button_spec.rb +44 -1
- data/lib/capybara/spec/session/click_link_spec.rb +11 -0
- data/lib/capybara/spec/session/evaluate_script_spec.rb +12 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +37 -2
- data/lib/capybara/spec/session/find_spec.rb +60 -6
- data/lib/capybara/spec/session/first_spec.rb +1 -1
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +14 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +12 -1
- data/lib/capybara/spec/session/has_ancestor_spec.rb +46 -0
- data/lib/capybara/spec/session/has_button_spec.rb +16 -0
- data/lib/capybara/spec/session/has_css_spec.rb +35 -6
- data/lib/capybara/spec/session/has_current_path_spec.rb +6 -4
- data/lib/capybara/spec/session/has_field_spec.rb +34 -0
- data/lib/capybara/spec/session/has_select_spec.rb +32 -4
- data/lib/capybara/spec/session/has_selector_spec.rb +4 -4
- data/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
- data/lib/capybara/spec/session/has_table_spec.rb +51 -5
- data/lib/capybara/spec/session/has_text_spec.rb +47 -0
- data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
- data/lib/capybara/spec/session/node_spec.rb +574 -16
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
- data/lib/capybara/spec/session/scroll_spec.rb +1 -1
- data/lib/capybara/spec/session/select_spec.rb +5 -10
- data/lib/capybara/spec/session/selectors_spec.rb +24 -3
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_spec.rb +10 -9
- data/lib/capybara/spec/spec_helper.rb +7 -2
- data/lib/capybara/spec/test_app.rb +26 -21
- data/lib/capybara/spec/views/animated.erb +49 -0
- data/lib/capybara/spec/views/form.erb +25 -4
- data/lib/capybara/spec/views/frame_child.erb +2 -1
- data/lib/capybara/spec/views/frame_one.erb +1 -0
- data/lib/capybara/spec/views/obscured.erb +9 -9
- data/lib/capybara/spec/views/offset.erb +32 -0
- data/lib/capybara/spec/views/react.erb +45 -0
- data/lib/capybara/spec/views/spatial.erb +31 -0
- data/lib/capybara/spec/views/with_animation.erb +29 -1
- data/lib/capybara/spec/views/with_dragula.erb +24 -0
- data/lib/capybara/spec/views/with_html.erb +28 -2
- data/lib/capybara/spec/views/with_js.erb +2 -1
- data/lib/capybara/spec/views/with_jstree.erb +26 -0
- data/lib/capybara/spec/views/with_sortable_js.erb +21 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +10 -10
- data/spec/basic_node_spec.rb +6 -6
- data/spec/capybara_spec.rb +28 -28
- data/spec/dsl_spec.rb +16 -3
- data/spec/filter_set_spec.rb +5 -5
- 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 +12 -2
- data/spec/minitest_spec_spec.rb +56 -45
- data/spec/rack_test_spec.rb +25 -12
- data/spec/regexp_dissassembler_spec.rb +53 -39
- data/spec/result_spec.rb +50 -54
- data/spec/rspec/features_spec.rb +1 -0
- data/spec/rspec/shared_spec_matchers.rb +78 -62
- data/spec/rspec_spec.rb +5 -5
- data/spec/sauce_spec_chrome.rb +1 -0
- data/spec/selector_spec.rb +26 -16
- data/spec/selenium_spec_chrome.rb +84 -5
- data/spec/selenium_spec_chrome_remote.rb +23 -8
- data/spec/selenium_spec_edge.rb +23 -8
- data/spec/selenium_spec_firefox.rb +16 -21
- data/spec/selenium_spec_firefox_remote.rb +4 -13
- data/spec/selenium_spec_ie.rb +23 -15
- data/spec/selenium_spec_safari.rb +17 -17
- data/spec/server_spec.rb +87 -42
- data/spec/session_spec.rb +11 -4
- data/spec/shared_selenium_node.rb +83 -0
- data/spec/shared_selenium_session.rb +62 -72
- data/spec/spec_helper.rb +43 -5
- metadata +114 -16
@@ -15,7 +15,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
|
|
15
15
|
@session.save_and_open_screenshot
|
16
16
|
|
17
17
|
expect(@session.driver).to have_received(:save_screenshot)
|
18
|
-
.with(expected_file_regex,
|
18
|
+
.with(expected_file_regex, any_args)
|
19
19
|
expect(Launchy).to have_received(:open).with(expected_file_regex)
|
20
20
|
end
|
21
21
|
|
@@ -27,7 +27,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
|
|
27
27
|
@session.save_and_open_screenshot(custom_path)
|
28
28
|
|
29
29
|
expect(@session.driver).to have_received(:save_screenshot)
|
30
|
-
.with(/#{custom_path}$/,
|
30
|
+
.with(/#{custom_path}$/, any_args)
|
31
31
|
expect(Launchy).to have_received(:open).with(/#{custom_path}$/)
|
32
32
|
end
|
33
33
|
|
@@ -19,7 +19,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
|
|
19
19
|
@session.save_screenshot
|
20
20
|
|
21
21
|
regexp = Regexp.new(File.join(Dir.pwd, 'capybara-\d+\.png'))
|
22
|
-
expect(@session.driver).to have_received(:save_screenshot).with(regexp,
|
22
|
+
expect(@session.driver).to have_received(:save_screenshot).with(regexp, any_args)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'allows to specify another path' do
|
@@ -28,7 +28,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
|
|
28
28
|
custom_path = 'screenshots/1.png'
|
29
29
|
@session.save_screenshot(custom_path)
|
30
30
|
|
31
|
-
expect(@session.driver).to have_received(:save_screenshot).with(/#{custom_path}$/,
|
31
|
+
expect(@session.driver).to have_received(:save_screenshot).with(/#{custom_path}$/, any_args)
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'with Capybara.save_path' do
|
@@ -39,7 +39,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
|
|
39
39
|
@session.save_screenshot
|
40
40
|
|
41
41
|
regexp = Regexp.new(File.join(alternative_path, 'capybara-\d+\.png'))
|
42
|
-
expect(@session.driver).to have_received(:save_screenshot).with(regexp,
|
42
|
+
expect(@session.driver).to have_received(:save_screenshot).with(regexp, any_args)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'relative paths are relative to save_path' do
|
@@ -49,7 +49,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
|
|
49
49
|
custom_path = 'screenshots/2.png'
|
50
50
|
@session.save_screenshot(custom_path)
|
51
51
|
|
52
|
-
expect(@session.driver).to have_received(:save_screenshot).with(File.expand_path(custom_path, alternative_path),
|
52
|
+
expect(@session.driver).to have_received(:save_screenshot).with(File.expand_path(custom_path, alternative_path), any_args)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -24,7 +24,7 @@ Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do
|
|
24
24
|
@session.scroll_to(el, align: :center)
|
25
25
|
el_center = el.evaluate_script('(function(rect){return (rect.top + rect.bottom)/2})(this.getBoundingClientRect())')
|
26
26
|
viewport_bottom = el.evaluate_script('document.body.clientHeight')
|
27
|
-
expect(el_center).to be_within(
|
27
|
+
expect(el_center).to be_within(2).of(viewport_bottom / 2)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'can scroll the window to the vertical top' do
|
@@ -42,13 +42,13 @@ Capybara::SpecHelper.spec '#select' do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should select an option from a select box by id' do
|
45
|
-
@session.select('
|
45
|
+
@session.select('Finnish', from: 'form_locale')
|
46
46
|
@session.click_button('awesome')
|
47
47
|
expect(extract_results(@session)['locale']).to eq('fi')
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should select an option from a select box by label' do
|
51
|
-
@session.select('
|
51
|
+
@session.select('Finnish', from: 'Locale')
|
52
52
|
@session.click_button('awesome')
|
53
53
|
expect(extract_results(@session)['locale']).to eq('fi')
|
54
54
|
end
|
@@ -141,11 +141,6 @@ Capybara::SpecHelper.spec '#select' do
|
|
141
141
|
@session.select('Other', from: 'form_title')
|
142
142
|
expect(@session.find_field('form_title').value).not_to eq 'Other'
|
143
143
|
end
|
144
|
-
|
145
|
-
it 'should warn' do
|
146
|
-
expect_any_instance_of(Capybara::Node::Element).to receive(:warn).once
|
147
|
-
@session.select('Other', from: 'form_title')
|
148
|
-
end
|
149
144
|
end
|
150
145
|
|
151
146
|
context 'with multiple select' do
|
@@ -188,7 +183,7 @@ Capybara::SpecHelper.spec '#select' do
|
|
188
183
|
context 'with :exact option' do
|
189
184
|
context 'when `false`' do
|
190
185
|
it 'can match select box approximately' do
|
191
|
-
@session.select('
|
186
|
+
@session.select('Finnish', from: 'Loc', exact: false)
|
192
187
|
@session.click_button('awesome')
|
193
188
|
expect(extract_results(@session)['locale']).to eq('fi')
|
194
189
|
end
|
@@ -209,13 +204,13 @@ Capybara::SpecHelper.spec '#select' do
|
|
209
204
|
context 'when `true`' do
|
210
205
|
it 'can match select box approximately' do
|
211
206
|
expect do
|
212
|
-
@session.select('
|
207
|
+
@session.select('Finnish', from: 'Loc', exact: true)
|
213
208
|
end.to raise_error(Capybara::ElementNotFound)
|
214
209
|
end
|
215
210
|
|
216
211
|
it 'can match option approximately' do
|
217
212
|
expect do
|
218
|
-
@session.select('Fin', from: 'Locale', exact:
|
213
|
+
@session.select('Fin', from: 'Locale', exact: true)
|
219
214
|
end.to raise_error(Capybara::ElementNotFound)
|
220
215
|
end
|
221
216
|
|
@@ -14,15 +14,28 @@ Capybara::SpecHelper.spec Capybara::Selector do
|
|
14
14
|
expect(@session.find(:label, for: 'form_other_title')['for']).to eq 'form_other_title'
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'finds a label for for attribute regex' do
|
18
|
+
expect(@session.find(:label, for: /_other_title/)['for']).to eq 'form_other_title'
|
19
|
+
end
|
20
|
+
|
17
21
|
it 'finds a label from nested input using :for filter with id string' do
|
18
22
|
expect(@session.find(:label, for: 'nested_label').text).to eq 'Nested Label'
|
19
23
|
end
|
20
24
|
|
25
|
+
it 'finds a label from nested input using :for filter with id regexp' do
|
26
|
+
expect(@session.find(:label, for: /nested_lab/).text).to eq 'Nested Label'
|
27
|
+
end
|
28
|
+
|
21
29
|
it 'finds a label from nested input using :for filter with element' do
|
22
30
|
input = @session.find(:id, 'nested_label')
|
23
31
|
expect(@session.find(:label, for: input).text).to eq 'Nested Label'
|
24
32
|
end
|
25
33
|
|
34
|
+
it 'finds a label from nested input using :for filter with element when no id on label' do
|
35
|
+
input = @session.find(:css, '#wrapper_label').find(:css, 'input')
|
36
|
+
expect(@session.find(:label, for: input).text).to eq 'Wrapper Label'
|
37
|
+
end
|
38
|
+
|
26
39
|
it 'finds the label for an non-nested element when using :for filter' do
|
27
40
|
select = @session.find(:id, 'form_other_title')
|
28
41
|
expect(@session.find(:label, for: select)['for']).to eq 'form_other_title'
|
@@ -54,14 +67,22 @@ Capybara::SpecHelper.spec Capybara::Selector do
|
|
54
67
|
end
|
55
68
|
end
|
56
69
|
|
57
|
-
it 'can find specifically by name' do
|
70
|
+
it 'can find specifically by name string' do
|
58
71
|
expect(@session.find(:field, name: 'form[other_title]')['id']).to eq 'form_other_title'
|
59
72
|
end
|
60
73
|
|
61
|
-
it 'can find specifically by
|
74
|
+
it 'can find specifically by name regex' do
|
75
|
+
expect(@session.find(:field, name: /form\[other_.*\]/)['id']).to eq 'form_other_title'
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'can find specifically by placeholder string' do
|
62
79
|
expect(@session.find(:field, placeholder: 'FirstName')['id']).to eq 'form_first_name'
|
63
80
|
end
|
64
81
|
|
82
|
+
it 'can find specifically by placeholder regex' do
|
83
|
+
expect(@session.find(:field, placeholder: /FirstN.*/)['id']).to eq 'form_first_name'
|
84
|
+
end
|
85
|
+
|
65
86
|
it 'can find by type' do
|
66
87
|
expect(@session.find(:field, 'Confusion', type: 'checkbox')['id']).to eq 'confusion_checkbox'
|
67
88
|
expect(@session.find(:field, 'Confusion', type: 'text')['id']).to eq 'confusion_text'
|
@@ -71,7 +92,7 @@ Capybara::SpecHelper.spec Capybara::Selector do
|
|
71
92
|
it 'can find by class' do
|
72
93
|
expect(@session.find(:field, class: 'confusion-checkbox')['id']).to eq 'confusion_checkbox'
|
73
94
|
expect(@session).to have_selector(:field, class: 'confusion', count: 3)
|
74
|
-
expect(@session.find(:field, class: [
|
95
|
+
expect(@session.find(:field, class: %w[confusion confusion-textarea])['id']).to eq 'confusion_textarea'
|
75
96
|
end
|
76
97
|
end
|
77
98
|
end
|
@@ -85,11 +85,11 @@ Capybara::SpecHelper.spec '#uncheck' do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'should raise original error when no label available' do
|
88
|
-
expect { @session.uncheck('form_cars_porsche') }.to raise_error(Capybara::ElementNotFound,
|
88
|
+
expect { @session.uncheck('form_cars_porsche') }.to raise_error(Capybara::ElementNotFound, /Unable to find visible checkbox "form_cars_porsche"/)
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should raise error if not allowed to click label' do
|
92
|
-
expect { @session.uncheck('form_cars_jaguar', allow_label_click: false) }.to raise_error(Capybara::ElementNotFound,
|
92
|
+
expect { @session.uncheck('form_cars_jaguar', allow_label_click: false) }.to raise_error(Capybara::ElementNotFound, /Unable to find visible checkbox "form_cars_jaguar"/)
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'should include node filter description in error if necessary' do
|
@@ -56,7 +56,7 @@ Capybara::SpecHelper.spec '#unselect' do
|
|
56
56
|
|
57
57
|
context "with a locator that doesn't exist" do
|
58
58
|
it 'should raise an error' do
|
59
|
-
msg =
|
59
|
+
msg = /Unable to find select box "does not exist"/
|
60
60
|
expect do
|
61
61
|
@session.unselect('foo', from: 'does not exist')
|
62
62
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
@@ -130,22 +130,23 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
130
130
|
other_window = @session.window_opened_by do
|
131
131
|
@session.find(:css, '#openWindow').click
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
|
+
other_window.resize_to(600, 400)
|
134
135
|
expect(@session.current_window).to eq(orig_window)
|
135
136
|
|
136
137
|
@session.within_window(other_window) do
|
137
|
-
expect(@session.current_window.size).to eq([600,
|
138
|
+
expect(@session.current_window.size).to eq([600, 400])
|
138
139
|
end
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
142
143
|
describe '#maximize' do
|
143
|
-
|
144
|
-
@
|
144
|
+
let! :initial_size do
|
145
|
+
@session.current_window.size
|
145
146
|
end
|
146
147
|
|
147
148
|
after do
|
148
|
-
@session.current_window.resize_to(
|
149
|
+
@session.current_window.resize_to(*initial_size)
|
149
150
|
sleep 0.5
|
150
151
|
end
|
151
152
|
|
@@ -175,7 +176,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
175
176
|
|
176
177
|
expect(@session.current_window).to eq(orig_window)
|
177
178
|
# Maximizing the browser affects all tabs so this may not be valid in real browsers
|
178
|
-
# expect(@session.current_window.size).to eq(
|
179
|
+
# expect(@session.current_window.size).to eq(initial_size)
|
179
180
|
|
180
181
|
ow_width, ow_height = other_window.size
|
181
182
|
expect(ow_width).to be > 400
|
@@ -184,12 +185,12 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
184
185
|
end
|
185
186
|
|
186
187
|
describe '#fullscreen' do
|
187
|
-
|
188
|
-
@
|
188
|
+
let! :initial_size do
|
189
|
+
@session.current_window.size
|
189
190
|
end
|
190
191
|
|
191
192
|
after do
|
192
|
-
@session.current_window.resize_to(
|
193
|
+
@session.current_window.resize_to(*initial_size)
|
193
194
|
sleep 1
|
194
195
|
end
|
195
196
|
|
@@ -30,12 +30,14 @@ module Capybara
|
|
30
30
|
Capybara.visible_text_only = false
|
31
31
|
Capybara.match = :smart
|
32
32
|
Capybara.enable_aria_label = false
|
33
|
+
Capybara.enable_aria_role = false
|
33
34
|
Capybara.default_set_options = {}
|
34
35
|
Capybara.disable_animation = false
|
35
36
|
Capybara.test_id = nil
|
36
37
|
Capybara.predicates_wait = true
|
37
38
|
Capybara.default_normalize_ws = false
|
38
39
|
Capybara.allow_gumbo = true
|
40
|
+
Capybara.w3c_click_offset = false
|
39
41
|
reset_threadsafe
|
40
42
|
end
|
41
43
|
|
@@ -59,7 +61,7 @@ module Capybara
|
|
59
61
|
RSpec.describe Capybara::Session, name, options do # rubocop:disable RSpec/EmptyExampleGroup
|
60
62
|
include Capybara::SpecHelper
|
61
63
|
include Capybara::RSpecMatchers
|
62
|
-
|
64
|
+
|
63
65
|
before do |example|
|
64
66
|
@session = session
|
65
67
|
instance_exec(example, &filter_block) if filter_block
|
@@ -80,7 +82,6 @@ module Capybara
|
|
80
82
|
before :each, :exact_false do
|
81
83
|
Capybara.exact = false
|
82
84
|
end
|
83
|
-
# rubocop:enable RSpec/ScatteredSetup
|
84
85
|
|
85
86
|
specs.each do |spec_name, spec_options, block|
|
86
87
|
describe spec_name, *spec_options do # rubocop:disable RSpec/EmptyExampleGroup
|
@@ -124,6 +125,10 @@ module Capybara
|
|
124
125
|
def be_an_invalid_element_error(session)
|
125
126
|
satisfy { |error| session.driver.invalid_element_errors.any? { |e| error.is_a? e } }
|
126
127
|
end
|
128
|
+
|
129
|
+
def with_os_path_separators(path)
|
130
|
+
Gem.win_platform? ? path.to_s.tr('/', '\\') : path.to_s
|
131
|
+
end
|
127
132
|
end
|
128
133
|
end
|
129
134
|
|
@@ -18,7 +18,6 @@ class TestApp < Sinatra::Base
|
|
18
18
|
set :raise_errors, true
|
19
19
|
set :show_exceptions, false
|
20
20
|
|
21
|
-
@@form_post_count = 0
|
22
21
|
# Also check lib/capybara/spec/views/*.erb for pages not listed here
|
23
22
|
|
24
23
|
get '/' do
|
@@ -176,8 +175,8 @@ class TestApp < Sinatra::Base
|
|
176
175
|
end
|
177
176
|
|
178
177
|
post '/form' do
|
179
|
-
|
180
|
-
'<pre id="results">' + params[:form].merge('post_count' =>
|
178
|
+
self.class.form_post_count += 1
|
179
|
+
'<pre id="results">' + params[:form].merge('post_count' => self.class.form_post_count).to_yaml + '</pre>'
|
181
180
|
end
|
182
181
|
|
183
182
|
post '/upload_empty' do
|
@@ -189,29 +188,35 @@ class TestApp < Sinatra::Base
|
|
189
188
|
end
|
190
189
|
|
191
190
|
post '/upload' do
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
'No file uploaded'
|
199
|
-
end
|
191
|
+
buffer = []
|
192
|
+
buffer << "Content-type: #{params.dig(:form, :document, :type)}"
|
193
|
+
buffer << "File content: #{params.dig(:form, :document, :tempfile).read}"
|
194
|
+
buffer.join(' | ')
|
195
|
+
rescue StandardError
|
196
|
+
'No file uploaded'
|
200
197
|
end
|
201
198
|
|
202
199
|
post '/upload_multiple' do
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
buffer << "File content: #{doc[:tempfile].read}"
|
209
|
-
end
|
210
|
-
buffer.join(' | ')
|
211
|
-
rescue StandardError
|
212
|
-
'No files uploaded'
|
200
|
+
docs = params.dig(:form, :multiple_documents)
|
201
|
+
buffer = [docs.size.to_s]
|
202
|
+
docs.each do |doc|
|
203
|
+
buffer << "Content-type: #{doc[:type]}"
|
204
|
+
buffer << "File content: #{doc[:tempfile].read}"
|
213
205
|
end
|
206
|
+
buffer.join(' | ')
|
207
|
+
rescue StandardError
|
208
|
+
'No files uploaded'
|
209
|
+
end
|
210
|
+
|
211
|
+
get '/apple-touch-icon-precomposed.png' do
|
212
|
+
halt(404)
|
214
213
|
end
|
214
|
+
|
215
|
+
class << self
|
216
|
+
attr_accessor :form_post_count
|
217
|
+
end
|
218
|
+
|
219
|
+
@form_post_count = 0
|
215
220
|
end
|
216
221
|
|
217
222
|
Rack::Handler::Puma.run TestApp, Port: 8070 if $PROGRAM_NAME == __FILE__
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
4
|
+
<title>with_animation</title>
|
5
|
+
<script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
|
6
|
+
<script>
|
7
|
+
$(document).on('contextmenu', function(e){ e.preventDefault(); });
|
8
|
+
</script>
|
9
|
+
<style>
|
10
|
+
div {
|
11
|
+
width: 400px;
|
12
|
+
height: 400px;
|
13
|
+
position: absolute;
|
14
|
+
}
|
15
|
+
#obscured {
|
16
|
+
z-index: 1;
|
17
|
+
background-color: red;
|
18
|
+
}
|
19
|
+
#cover {
|
20
|
+
z-index: 2;
|
21
|
+
background-color: blue;
|
22
|
+
}
|
23
|
+
#offscreen {
|
24
|
+
top: 2000px;
|
25
|
+
left: 2000px;
|
26
|
+
background-color: green;
|
27
|
+
}
|
28
|
+
#offscreen_wrapper {
|
29
|
+
top: 2000px;
|
30
|
+
left: 2000px;
|
31
|
+
overflow-x: scroll;
|
32
|
+
background-color: yellow;
|
33
|
+
}
|
34
|
+
</style>
|
35
|
+
</head>
|
36
|
+
|
37
|
+
<body id="with_animation">
|
38
|
+
<div id="obscured">
|
39
|
+
<input id="obscured_input"/>
|
40
|
+
</div>
|
41
|
+
<div id="cover"></div>
|
42
|
+
<div id="offscreen_wrapper">
|
43
|
+
<div id="offscreen"></div>
|
44
|
+
</div>
|
45
|
+
</body>
|
46
|
+
|
47
|
+
<iframe id="frameOne" src="/frame_one"></iframe>
|
48
|
+
</html>
|
49
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
<h1>Form</h1>
|
3
3
|
|
4
|
-
<form action="/form" method="post">
|
4
|
+
<form action="/form" method="post" novalidate>
|
5
5
|
|
6
6
|
<p>
|
7
7
|
<label for="form_title">Title</label>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<option>Miss</option>
|
12
12
|
<option disabled="disabled">Other</option>
|
13
13
|
</select>
|
14
|
-
|
14
|
+
</p>
|
15
15
|
|
16
16
|
<p>
|
17
17
|
<label for="customer_name">Customer Name
|
@@ -62,6 +62,11 @@
|
|
62
62
|
<input type="text" name="form[name]" value="John Smith" id="form_name"/>
|
63
63
|
</p>
|
64
64
|
|
65
|
+
<p>
|
66
|
+
<label for="form_age">Age</label>
|
67
|
+
<input type="range" name="form[age]" value="18" min="13" max="100" step="0.5" id="form_age"/>
|
68
|
+
</p>
|
69
|
+
|
65
70
|
<p>
|
66
71
|
<label for="form_schmooo">Schmooo</label>
|
67
72
|
<input type="schmooo" name="form[schmooo]" value="This is Schmooo!" id="form_schmooo"/>
|
@@ -108,7 +113,7 @@
|
|
108
113
|
<select name="form[locale]" id="form_locale">
|
109
114
|
<option value="sv">Swedish</option>
|
110
115
|
<option selected="selected" value="en">English</option>
|
111
|
-
<option value="fi">
|
116
|
+
<option value="fi">Finnish</option>
|
112
117
|
<option value="no">Norwegian</option>
|
113
118
|
<option value="jo">John's made-up language</option>
|
114
119
|
<option value="jbo"> Lojban </option>
|
@@ -135,7 +140,11 @@
|
|
135
140
|
|
136
141
|
<p>
|
137
142
|
<label for="form_zipcode">Zipcode</label>
|
138
|
-
<input type="text" maxlength="5" name="form[zipcode]" id="form_zipcode" />
|
143
|
+
<input type="text" maxlength="5" name="form[zipcode]" id="form_zipcode" pattern="[0-9]{5,9}" />
|
144
|
+
</p>
|
145
|
+
|
146
|
+
<p>
|
147
|
+
<input maxlength="35" id="long_length" />
|
139
148
|
</p>
|
140
149
|
|
141
150
|
<p>
|
@@ -448,6 +457,7 @@ New line after and before textarea tag
|
|
448
457
|
<button id="no_type">No Type!</button>
|
449
458
|
<button><img alt="A horse eating hay"/></button>
|
450
459
|
<input type="button" disabled="disabled" value="Disabled button"/>
|
460
|
+
<span role="button">ARIA button</span>
|
451
461
|
</p>
|
452
462
|
|
453
463
|
<p>
|
@@ -460,6 +470,11 @@ New line after and before textarea tag
|
|
460
470
|
<input id="readonly" name="form[readonly_test]" readonly/>
|
461
471
|
<input id="not_readonly" name="form[readonly_test]" />
|
462
472
|
</p>
|
473
|
+
|
474
|
+
<p>
|
475
|
+
<input id="required" name="form[required]" required />
|
476
|
+
<input id="length" name="form[length]" minlength="4" maxlength="4" />
|
477
|
+
</p>
|
463
478
|
</form>
|
464
479
|
|
465
480
|
<input type="text" name="form[outside_input]" value="outside_input" form="form1"/>
|
@@ -469,6 +484,11 @@ New line after and before textarea tag
|
|
469
484
|
<input type="text" name="nested_label" id="nested_label"/>
|
470
485
|
</label>
|
471
486
|
|
487
|
+
<label id="wrapper_label">
|
488
|
+
Wrapper Label
|
489
|
+
<input type="checkbox"/>
|
490
|
+
</label>
|
491
|
+
|
472
492
|
<form id="form1" action="/form" method="post">
|
473
493
|
<input type="text" name="form[which_form]" value="form1" id="form_which_form"/>
|
474
494
|
<input type="text" name="form[for_form2]" value="for_form2" form="form2"/>
|
@@ -502,6 +522,7 @@ New line after and before textarea tag
|
|
502
522
|
|
503
523
|
<p>
|
504
524
|
<input type="submit" name="form[mediocre]" id="mediocre" value="med" aria-label="Mediocre Button"/>
|
525
|
+
<input type="submit" formaction="/form/get?bar=foo" id="mediocre2" value="med2"/>
|
505
526
|
<p>
|
506
527
|
</form>
|
507
528
|
|