capybara 3.3.0 → 3.40.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 +803 -13
- data/License.txt +1 -1
- data/README.md +257 -84
- data/lib/capybara/config.rb +25 -9
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/base.rb +17 -3
- data/lib/capybara/driver/node.rb +31 -6
- data/lib/capybara/dsl.rb +9 -7
- data/lib/capybara/helpers.rb +31 -7
- data/lib/capybara/minitest/spec.rb +180 -88
- data/lib/capybara/minitest.rb +262 -149
- data/lib/capybara/node/actions.rb +202 -116
- data/lib/capybara/node/base.rb +34 -19
- data/lib/capybara/node/document.rb +14 -2
- data/lib/capybara/node/document_matchers.rb +10 -12
- data/lib/capybara/node/element.rb +269 -115
- data/lib/capybara/node/finders.rb +99 -77
- data/lib/capybara/node/matchers.rb +327 -151
- data/lib/capybara/node/simple.rb +48 -13
- data/lib/capybara/node/whitespace_normalizer.rb +81 -0
- data/lib/capybara/queries/active_element_query.rb +18 -0
- data/lib/capybara/queries/ancestor_query.rb +8 -9
- data/lib/capybara/queries/base_query.rb +23 -16
- data/lib/capybara/queries/current_path_query.rb +16 -6
- data/lib/capybara/queries/match_query.rb +1 -0
- data/lib/capybara/queries/selector_query.rb +587 -130
- data/lib/capybara/queries/sibling_query.rb +8 -6
- data/lib/capybara/queries/style_query.rb +6 -2
- data/lib/capybara/queries/text_query.rb +28 -14
- data/lib/capybara/queries/title_query.rb +2 -2
- data/lib/capybara/rack_test/browser.rb +92 -25
- data/lib/capybara/rack_test/driver.rb +16 -7
- data/lib/capybara/rack_test/errors.rb +6 -0
- data/lib/capybara/rack_test/form.rb +68 -41
- data/lib/capybara/rack_test/node.rb +106 -39
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/registration_container.rb +41 -0
- data/lib/capybara/registrations/drivers.rb +42 -0
- data/lib/capybara/registrations/patches/puma_ssl.rb +29 -0
- data/lib/capybara/registrations/servers.rb +66 -0
- data/lib/capybara/result.rb +75 -52
- data/lib/capybara/rspec/features.rb +7 -7
- data/lib/capybara/rspec/matcher_proxies.rb +39 -18
- data/lib/capybara/rspec/matchers/base.rb +113 -0
- data/lib/capybara/rspec/matchers/become_closed.rb +33 -0
- data/lib/capybara/rspec/matchers/compound.rb +88 -0
- 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 +29 -0
- data/lib/capybara/rspec/matchers/have_selector.rb +69 -0
- data/lib/capybara/rspec/matchers/have_sibling.rb +27 -0
- data/lib/capybara/rspec/matchers/have_text.rb +33 -0
- data/lib/capybara/rspec/matchers/have_title.rb +29 -0
- data/lib/capybara/rspec/matchers/match_selector.rb +27 -0
- data/lib/capybara/rspec/matchers/match_style.rb +43 -0
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
- data/lib/capybara/rspec/matchers.rb +141 -339
- data/lib/capybara/rspec.rb +2 -0
- data/lib/capybara/selector/builders/css_builder.rb +84 -0
- data/lib/capybara/selector/builders/xpath_builder.rb +71 -0
- data/lib/capybara/selector/css.rb +27 -25
- data/lib/capybara/selector/definition/button.rb +68 -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 +28 -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 +55 -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/definition.rb +280 -0
- data/lib/capybara/selector/filter.rb +1 -0
- data/lib/capybara/selector/filter_set.rb +73 -25
- data/lib/capybara/selector/filters/base.rb +24 -5
- data/lib/capybara/selector/filters/expression_filter.rb +3 -3
- data/lib/capybara/selector/filters/locator_filter.rb +29 -0
- data/lib/capybara/selector/filters/node_filter.rb +16 -2
- data/lib/capybara/selector/regexp_disassembler.rb +211 -0
- data/lib/capybara/selector/selector.rb +85 -348
- data/lib/capybara/selector/xpath_extensions.rb +17 -0
- data/lib/capybara/selector.rb +474 -447
- 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 +255 -143
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +93 -11
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +128 -0
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +84 -0
- data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +26 -0
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +24 -0
- data/lib/capybara/selenium/extensions/file_input_click_emulation.rb +34 -0
- data/lib/capybara/selenium/extensions/find.rb +110 -0
- data/lib/capybara/selenium/extensions/html5_drag.rb +229 -0
- data/lib/capybara/selenium/extensions/modifier_keys_stack.rb +28 -0
- data/lib/capybara/selenium/extensions/scroll.rb +76 -0
- data/lib/capybara/selenium/node.rb +436 -134
- data/lib/capybara/selenium/nodes/chrome_node.rb +125 -0
- data/lib/capybara/selenium/nodes/edge_node.rb +110 -0
- data/lib/capybara/selenium/nodes/firefox_node.rb +136 -0
- data/lib/capybara/selenium/nodes/ie_node.rb +22 -0
- data/lib/capybara/selenium/nodes/safari_node.rb +118 -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/selenium/patches/pause_duration_fix.rb +9 -0
- data/lib/capybara/selenium/patches/persistent_client.rb +20 -0
- data/lib/capybara/server/animation_disabler.rb +56 -19
- data/lib/capybara/server/checker.rb +9 -3
- data/lib/capybara/server/middleware.rb +28 -12
- data/lib/capybara/server.rb +33 -10
- data/lib/capybara/session/config.rb +34 -10
- data/lib/capybara/session/matchers.rb +23 -16
- data/lib/capybara/session.rb +230 -170
- data/lib/capybara/spec/public/jquery.js +5 -5
- data/lib/capybara/spec/public/offset.js +6 -0
- data/lib/capybara/spec/public/test.js +121 -8
- data/lib/capybara/spec/session/accept_alert_spec.rb +11 -11
- 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/active_element_spec.rb +31 -0
- data/lib/capybara/spec/session/all_spec.rb +127 -40
- data/lib/capybara/spec/session/ancestor_spec.rb +24 -19
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +67 -38
- data/lib/capybara/spec/session/assert_current_path_spec.rb +21 -18
- data/lib/capybara/spec/session/assert_selector_spec.rb +52 -58
- data/lib/capybara/spec/session/assert_style_spec.rb +7 -7
- data/lib/capybara/spec/session/assert_text_spec.rb +74 -50
- data/lib/capybara/spec/session/assert_title_spec.rb +12 -12
- data/lib/capybara/spec/session/attach_file_spec.rb +126 -72
- data/lib/capybara/spec/session/body_spec.rb +6 -6
- data/lib/capybara/spec/session/check_spec.rb +102 -47
- data/lib/capybara/spec/session/choose_spec.rb +58 -32
- data/lib/capybara/spec/session/click_button_spec.rb +219 -163
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +49 -23
- data/lib/capybara/spec/session/click_link_spec.rb +77 -54
- data/lib/capybara/spec/session/current_scope_spec.rb +8 -8
- data/lib/capybara/spec/session/current_url_spec.rb +38 -29
- 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 +16 -10
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +6 -6
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +68 -56
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +7 -7
- data/lib/capybara/spec/session/evaluate_script_spec.rb +28 -8
- data/lib/capybara/spec/session/execute_script_spec.rb +8 -7
- data/lib/capybara/spec/session/fill_in_spec.rb +101 -46
- 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 +31 -21
- data/lib/capybara/spec/session/find_spec.rb +244 -141
- data/lib/capybara/spec/session/first_spec.rb +43 -43
- 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 +30 -18
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +45 -18
- 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 +23 -23
- data/lib/capybara/spec/session/has_ancestor_spec.rb +46 -0
- data/lib/capybara/spec/session/has_any_selectors_spec.rb +29 -0
- data/lib/capybara/spec/session/has_button_spec.rb +94 -13
- data/lib/capybara/spec/session/has_css_spec.rb +272 -132
- data/lib/capybara/spec/session/has_current_path_spec.rb +50 -35
- data/lib/capybara/spec/session/has_element_spec.rb +47 -0
- data/lib/capybara/spec/session/has_field_spec.rb +137 -58
- data/lib/capybara/spec/session/has_link_spec.rb +44 -4
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +31 -31
- data/lib/capybara/spec/session/has_select_spec.rb +84 -50
- data/lib/capybara/spec/session/has_selector_spec.rb +111 -71
- data/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
- data/lib/capybara/spec/session/has_table_spec.rb +181 -4
- data/lib/capybara/spec/session/has_text_spec.rb +101 -53
- data/lib/capybara/spec/session/has_title_spec.rb +19 -14
- data/lib/capybara/spec/session/has_xpath_spec.rb +56 -38
- data/lib/capybara/spec/session/headers_spec.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +13 -6
- data/lib/capybara/spec/session/matches_style_spec.rb +37 -0
- data/lib/capybara/spec/session/node_spec.rb +894 -142
- data/lib/capybara/spec/session/node_wrapper_spec.rb +10 -7
- data/lib/capybara/spec/session/refresh_spec.rb +9 -7
- data/lib/capybara/spec/session/reset_session_spec.rb +63 -35
- 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_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_page_spec.rb +37 -37
- data/lib/capybara/spec/session/save_screenshot_spec.rb +10 -10
- data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/scroll_spec.rb +119 -0
- data/lib/capybara/spec/session/select_spec.rb +85 -85
- data/lib/capybara/spec/session/selectors_spec.rb +49 -18
- data/lib/capybara/spec/session/sibling_spec.rb +9 -9
- data/lib/capybara/spec/session/text_spec.rb +25 -24
- data/lib/capybara/spec/session/title_spec.rb +7 -6
- data/lib/capybara/spec/session/uncheck_spec.rb +33 -21
- data/lib/capybara/spec/session/unselect_spec.rb +37 -37
- data/lib/capybara/spec/session/visit_spec.rb +68 -49
- data/lib/capybara/spec/session/window/become_closed_spec.rb +20 -17
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +20 -16
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +6 -2
- data/lib/capybara/spec/session/window/window_spec.rb +62 -63
- data/lib/capybara/spec/session/window/windows_spec.rb +5 -1
- data/lib/capybara/spec/session/window/within_window_spec.rb +14 -14
- data/lib/capybara/spec/session/within_spec.rb +79 -42
- data/lib/capybara/spec/spec_helper.rb +41 -53
- data/lib/capybara/spec/test_app.rb +132 -43
- data/lib/capybara/spec/views/animated.erb +49 -0
- data/lib/capybara/spec/views/form.erb +139 -42
- data/lib/capybara/spec/views/frame_child.erb +4 -3
- data/lib/capybara/spec/views/frame_one.erb +2 -1
- data/lib/capybara/spec/views/frame_parent.erb +1 -1
- data/lib/capybara/spec/views/frame_two.erb +1 -1
- data/lib/capybara/spec/views/initial_alert.erb +2 -1
- data/lib/capybara/spec/views/layout.erb +10 -0
- data/lib/capybara/spec/views/obscured.erb +47 -0
- data/lib/capybara/spec/views/offset.erb +33 -0
- data/lib/capybara/spec/views/path.erb +2 -2
- data/lib/capybara/spec/views/popup_one.erb +1 -1
- data/lib/capybara/spec/views/popup_two.erb +1 -1
- data/lib/capybara/spec/views/react.erb +45 -0
- data/lib/capybara/spec/views/scroll.erb +21 -0
- data/lib/capybara/spec/views/spatial.erb +31 -0
- data/lib/capybara/spec/views/tables.erb +67 -0
- data/lib/capybara/spec/views/with_animation.erb +39 -4
- data/lib/capybara/spec/views/with_base_tag.erb +2 -2
- data/lib/capybara/spec/views/with_dragula.erb +24 -0
- data/lib/capybara/spec/views/with_fixed_header_footer.erb +2 -1
- data/lib/capybara/spec/views/with_hover.erb +3 -2
- data/lib/capybara/spec/views/with_hover1.erb +10 -0
- data/lib/capybara/spec/views/with_html.erb +37 -9
- data/lib/capybara/spec/views/with_html5_svg.erb +20 -0
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +26 -5
- data/lib/capybara/spec/views/with_jstree.erb +26 -0
- data/lib/capybara/spec/views/with_namespace.erb +1 -0
- data/lib/capybara/spec/views/with_scope.erb +2 -2
- data/lib/capybara/spec/views/with_scope_other.erb +6 -0
- data/lib/capybara/spec/views/with_shadow.erb +31 -0
- data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
- data/lib/capybara/spec/views/with_sortable_js.erb +21 -0
- data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
- data/lib/capybara/spec/views/with_windows.erb +1 -1
- data/lib/capybara/spec/views/within_frames.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +19 -25
- data/lib/capybara.rb +126 -111
- data/spec/basic_node_spec.rb +59 -34
- data/spec/capybara_spec.rb +56 -44
- data/spec/counter_spec.rb +35 -0
- data/spec/css_builder_spec.rb +101 -0
- data/spec/css_splitter_spec.rb +8 -8
- data/spec/dsl_spec.rb +79 -52
- data/spec/filter_set_spec.rb +9 -9
- data/spec/fixtures/selenium_driver_rspec_failure.rb +4 -4
- data/spec/fixtures/selenium_driver_rspec_success.rb +4 -4
- data/spec/minitest_spec.rb +45 -7
- data/spec/minitest_spec_spec.rb +87 -64
- data/spec/per_session_config_spec.rb +6 -6
- data/spec/rack_test_spec.rb +172 -116
- data/spec/regexp_dissassembler_spec.rb +250 -0
- data/spec/result_spec.rb +80 -72
- data/spec/rspec/features_spec.rb +21 -16
- data/spec/rspec/scenarios_spec.rb +10 -6
- data/spec/rspec/shared_spec_matchers.rb +407 -365
- data/spec/rspec/views_spec.rb +3 -3
- data/spec/rspec_matchers_spec.rb +35 -10
- data/spec/rspec_spec.rb +63 -41
- data/spec/sauce_spec_chrome.rb +43 -0
- data/spec/selector_spec.rb +334 -89
- data/spec/selenium_spec_chrome.rb +176 -62
- data/spec/selenium_spec_chrome_remote.rb +54 -14
- data/spec/selenium_spec_edge.rb +41 -8
- data/spec/selenium_spec_firefox.rb +228 -0
- data/spec/selenium_spec_firefox_remote.rb +94 -0
- data/spec/selenium_spec_ie.rb +129 -11
- data/spec/selenium_spec_safari.rb +162 -0
- data/spec/server_spec.rb +171 -97
- data/spec/session_spec.rb +34 -18
- data/spec/shared_selenium_node.rb +79 -0
- data/spec/shared_selenium_session.rb +344 -80
- data/spec/spec_helper.rb +124 -2
- data/spec/whitespace_normalizer_spec.rb +54 -0
- data/spec/xpath_builder_spec.rb +93 -0
- metadata +326 -28
- data/lib/capybara/rspec/compound.rb +0 -94
- data/lib/capybara/selenium/driver_specializations/marionette_driver.rb +0 -31
- data/lib/capybara/selenium/nodes/marionette_node.rb +0 -31
- data/lib/capybara/spec/session/has_style_spec.rb +0 -25
- data/lib/capybara/spec/session/source_spec.rb +0 -0
- data/lib/capybara/spec/views/with_title.erb +0 -5
- data/spec/selenium_spec_marionette.rb +0 -167
@@ -5,426 +5,482 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
5
5
|
@session.visit('/form')
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should wait for asynchronous load', requires: [:js] do
|
9
9
|
@session.visit('/with_js')
|
10
|
-
@session.
|
11
|
-
|
10
|
+
@session.using_wait_time(1.5) do
|
11
|
+
@session.click_link('Click me')
|
12
|
+
@session.click_button('New Here')
|
13
|
+
end
|
12
14
|
end
|
13
15
|
|
14
|
-
it
|
16
|
+
it 'casts to string' do
|
15
17
|
@session.click_button(:'Relative Action')
|
16
18
|
expect(extract_results(@session)['relative']).to eq('Relative Action')
|
17
19
|
expect(@session.current_path).to eq('/relative')
|
18
20
|
end
|
19
21
|
|
20
|
-
context
|
21
|
-
it
|
22
|
+
context 'with multiple values with the same name' do
|
23
|
+
it 'should use the latest given value' do
|
22
24
|
@session.check('Terms of Use')
|
23
25
|
@session.click_button('awesome')
|
24
26
|
expect(extract_results(@session)['terms_of_use']).to eq('1')
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
context
|
29
|
-
it
|
30
|
+
context 'with a form that has a relative url as an action' do
|
31
|
+
it 'should post to the correct url' do
|
30
32
|
@session.click_button('Relative Action')
|
31
33
|
expect(extract_results(@session)['relative']).to eq('Relative Action')
|
32
34
|
expect(@session.current_path).to eq('/relative')
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
|
-
context
|
37
|
-
it
|
38
|
+
context 'with a form that has no action specified' do
|
39
|
+
it 'should post to the correct url' do
|
38
40
|
@session.click_button('No Action')
|
39
41
|
expect(extract_results(@session)['no_action']).to eq('No Action')
|
40
42
|
expect(@session.current_path).to eq('/form')
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
context
|
45
|
-
context
|
46
|
+
context 'with value given on a submit button' do
|
47
|
+
context 'on a form with HTML5 fields' do
|
48
|
+
let(:results) { extract_results(@session) }
|
49
|
+
|
46
50
|
before do
|
47
51
|
@session.click_button('html5_submit')
|
48
|
-
@results = extract_results(@session)
|
49
52
|
end
|
50
53
|
|
51
|
-
it
|
52
|
-
expect(
|
54
|
+
it 'should serialise and submit search fields' do
|
55
|
+
expect(results['html5_search']).to eq('what are you looking for')
|
53
56
|
end
|
54
57
|
|
55
|
-
it
|
56
|
-
expect(
|
58
|
+
it 'should serialise and submit email fields' do
|
59
|
+
expect(results['html5_email']).to eq('person@email.com')
|
57
60
|
end
|
58
61
|
|
59
|
-
it
|
60
|
-
expect(
|
62
|
+
it 'should serialise and submit url fields' do
|
63
|
+
expect(results['html5_url']).to eq('http://www.example.com')
|
61
64
|
end
|
62
65
|
|
63
|
-
it
|
64
|
-
expect(
|
66
|
+
it 'should serialise and submit tel fields' do
|
67
|
+
expect(results['html5_tel']).to eq('911')
|
65
68
|
end
|
66
69
|
|
67
|
-
it
|
68
|
-
expect(
|
70
|
+
it 'should serialise and submit color fields' do
|
71
|
+
expect(results['html5_color'].upcase).to eq('#FFFFFF')
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
72
|
-
context
|
75
|
+
context 'on an HTML4 form' do
|
76
|
+
let(:results) { extract_results(@session) }
|
77
|
+
|
73
78
|
before do
|
74
79
|
@session.click_button('awesome')
|
75
|
-
@results = extract_results(@session)
|
76
80
|
end
|
77
81
|
|
78
|
-
it
|
79
|
-
expect(
|
82
|
+
it 'should serialize and submit text fields' do
|
83
|
+
expect(results['first_name']).to eq('John')
|
80
84
|
end
|
81
85
|
|
82
|
-
it
|
83
|
-
expect(
|
86
|
+
it 'should escape fields when submitting' do
|
87
|
+
expect(results['phone']).to eq('+1 555 7021')
|
84
88
|
end
|
85
89
|
|
86
|
-
it
|
87
|
-
expect(
|
90
|
+
it 'should serialize and submit password fields' do
|
91
|
+
expect(results['password']).to eq('seeekrit')
|
88
92
|
end
|
89
93
|
|
90
|
-
it
|
91
|
-
expect(
|
94
|
+
it 'should serialize and submit hidden fields' do
|
95
|
+
expect(results['token']).to eq('12345')
|
92
96
|
end
|
93
97
|
|
94
|
-
it
|
95
|
-
expect(
|
98
|
+
it 'should not serialize fields from other forms' do
|
99
|
+
expect(results['middle_name']).to be_nil
|
96
100
|
end
|
97
101
|
|
98
|
-
it
|
99
|
-
expect(
|
100
|
-
expect(
|
102
|
+
it 'should submit the button that was clicked, but not other buttons' do
|
103
|
+
expect(results['awesome']).to eq('awesome')
|
104
|
+
expect(results['crappy']).to be_nil
|
101
105
|
end
|
102
106
|
|
103
|
-
it
|
104
|
-
expect(
|
107
|
+
it 'should serialize radio buttons' do
|
108
|
+
expect(results['gender']).to eq('female')
|
105
109
|
end
|
106
110
|
|
107
111
|
it "should default radio value to 'on' if none specified" do
|
108
|
-
expect(
|
112
|
+
expect(results['valueless_radio']).to eq('on')
|
109
113
|
end
|
110
114
|
|
111
|
-
it
|
112
|
-
expect(
|
113
|
-
expect(
|
115
|
+
it 'should serialize check boxes' do
|
116
|
+
expect(results['pets']).to include('dog', 'hamster')
|
117
|
+
expect(results['pets']).not_to include('cat')
|
114
118
|
end
|
115
119
|
|
116
120
|
it "should default checkbox value to 'on' if none specififed" do
|
117
|
-
expect(
|
121
|
+
expect(results['valueless_checkbox']).to eq('on')
|
118
122
|
end
|
119
123
|
|
120
|
-
it
|
121
|
-
expect(
|
124
|
+
it 'should serialize text areas' do
|
125
|
+
expect(results['description']).to eq('Descriptive text goes here')
|
122
126
|
end
|
123
127
|
|
124
|
-
it
|
125
|
-
expect(
|
128
|
+
it 'should serialize select tag with values' do
|
129
|
+
expect(results['locale']).to eq('en')
|
126
130
|
end
|
127
131
|
|
128
|
-
it
|
129
|
-
expect(
|
132
|
+
it 'should serialize select tag without values' do
|
133
|
+
expect(results['region']).to eq('Norway')
|
130
134
|
end
|
131
135
|
|
132
|
-
it
|
133
|
-
expect(
|
136
|
+
it 'should serialize first option for select tag with no selection' do
|
137
|
+
expect(results['city']).to eq('London')
|
134
138
|
end
|
135
139
|
|
136
|
-
it
|
137
|
-
expect(
|
140
|
+
it 'should not serialize a select tag without options' do
|
141
|
+
expect(results['tendency']).to be_nil
|
138
142
|
end
|
139
143
|
|
140
|
-
it
|
141
|
-
expect(
|
144
|
+
it 'should convert lf to cr/lf in submitted textareas' do
|
145
|
+
expect(results['newline']).to eq("\r\nNew line after and before textarea tag\r\n")
|
142
146
|
end
|
143
147
|
|
144
|
-
it
|
145
|
-
expect(
|
146
|
-
expect(
|
147
|
-
expect(
|
148
|
-
expect(
|
149
|
-
expect(
|
150
|
-
expect(
|
148
|
+
it 'should not submit disabled fields' do
|
149
|
+
expect(results['disabled_text_field']).to be_nil
|
150
|
+
expect(results['disabled_textarea']).to be_nil
|
151
|
+
expect(results['disabled_checkbox']).to be_nil
|
152
|
+
expect(results['disabled_radio']).to be_nil
|
153
|
+
expect(results['disabled_select']).to be_nil
|
154
|
+
expect(results['disabled_file']).to be_nil
|
151
155
|
end
|
152
156
|
end
|
153
157
|
end
|
154
158
|
|
155
|
-
context
|
156
|
-
it
|
159
|
+
context 'input type=submit button' do
|
160
|
+
it 'should submit by button id' do
|
157
161
|
@session.click_button('awe123')
|
158
162
|
expect(extract_results(@session)['first_name']).to eq('John')
|
159
163
|
end
|
160
164
|
|
161
|
-
it
|
165
|
+
it 'should submit by specific button id' do
|
166
|
+
@session.click_button(id: 'awe123')
|
167
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should submit by button title' do
|
162
171
|
@session.click_button('What an Awesome Button')
|
163
172
|
expect(extract_results(@session)['first_name']).to eq('John')
|
164
173
|
end
|
165
174
|
|
166
|
-
it
|
175
|
+
it 'should submit by partial title', :exact_false do
|
167
176
|
@session.click_button('What an Awesome')
|
168
177
|
expect(extract_results(@session)['first_name']).to eq('John')
|
169
178
|
end
|
179
|
+
|
180
|
+
it 'should submit by button name' do
|
181
|
+
@session.click_button('form[awesome]')
|
182
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should submit by specific button name' do
|
186
|
+
@session.click_button(name: 'form[awesome]')
|
187
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should submit by specific button name regex' do
|
191
|
+
@session.click_button(name: /form\[awes.*\]/)
|
192
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
193
|
+
end
|
170
194
|
end
|
171
195
|
|
172
|
-
context
|
196
|
+
context 'when Capybara.enable_aria_role = true' do
|
197
|
+
it 'should click on a button role', requires: [:js] do
|
198
|
+
Capybara.enable_aria_role = true
|
199
|
+
@session.using_wait_time(1.5) do
|
200
|
+
@session.visit('/with_js')
|
201
|
+
@session.click_button('ARIA button')
|
202
|
+
expect(@session).to have_button('ARIA button has been clicked')
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'with fields associated with the form using the form attribute', requires: [:form_attribute] do
|
208
|
+
let(:results) { extract_results(@session) }
|
209
|
+
|
173
210
|
before do
|
174
211
|
@session.click_button('submit_form1')
|
175
|
-
@results = extract_results(@session)
|
176
212
|
end
|
177
213
|
|
178
|
-
it
|
179
|
-
expect(
|
214
|
+
it 'should serialize and submit text fields' do
|
215
|
+
expect(results['outside_input']).to eq('outside_input')
|
180
216
|
end
|
181
217
|
|
182
|
-
it
|
183
|
-
expect(
|
218
|
+
it 'should serialize text areas' do
|
219
|
+
expect(results['outside_textarea']).to eq('Some text here')
|
184
220
|
end
|
185
221
|
|
186
|
-
it
|
187
|
-
expect(
|
222
|
+
it 'should serialize select tags' do
|
223
|
+
expect(results['outside_select']).to eq('Ruby')
|
188
224
|
end
|
189
225
|
|
190
|
-
it
|
191
|
-
expect(
|
226
|
+
it 'should not serliaze fields associated with a different form' do
|
227
|
+
expect(results['for_form2']).to be_nil
|
192
228
|
end
|
193
229
|
end
|
194
230
|
|
195
|
-
context
|
231
|
+
context 'with submit button outside the form defined by <button> tag', requires: [:form_attribute] do
|
232
|
+
let(:results) { extract_results(@session) }
|
233
|
+
|
196
234
|
before do
|
197
235
|
@session.click_button('outside_button')
|
198
|
-
@results = extract_results(@session)
|
199
236
|
end
|
200
237
|
|
201
|
-
it
|
202
|
-
expect(
|
238
|
+
it 'should submit the associated form' do
|
239
|
+
expect(results['which_form']).to eq('form2')
|
203
240
|
end
|
204
241
|
|
205
|
-
it
|
206
|
-
expect(
|
207
|
-
expect(
|
242
|
+
it 'should submit the button that was clicked, but not other buttons' do
|
243
|
+
expect(results['outside_button']).to eq('outside_button')
|
244
|
+
expect(results['unused']).to be_nil
|
208
245
|
end
|
209
246
|
end
|
210
247
|
|
211
248
|
context "with submit button outside the form defined by <input type='submit'> tag", requires: [:form_attribute] do
|
249
|
+
let(:results) { extract_results(@session) }
|
250
|
+
|
212
251
|
before do
|
213
252
|
@session.click_button('outside_submit')
|
214
|
-
@results = extract_results(@session)
|
215
253
|
end
|
216
254
|
|
217
|
-
it
|
218
|
-
expect(
|
255
|
+
it 'should submit the associated form' do
|
256
|
+
expect(results['which_form']).to eq('form1')
|
219
257
|
end
|
220
258
|
|
221
|
-
it
|
222
|
-
expect(
|
223
|
-
expect(
|
259
|
+
it 'should submit the button that was clicked, but not other buttons' do
|
260
|
+
expect(results['outside_submit']).to eq('outside_submit')
|
261
|
+
expect(results['submit_form1']).to be_nil
|
224
262
|
end
|
225
263
|
end
|
226
264
|
|
227
|
-
context
|
228
|
-
it
|
265
|
+
context 'with submit button for form1 located within form2', requires: [:form_attribute] do
|
266
|
+
it 'should submit the form associated with the button' do
|
229
267
|
@session.click_button('other_form_button')
|
230
|
-
expect(extract_results(@session)['which_form']).to eq(
|
268
|
+
expect(extract_results(@session)['which_form']).to eq('form1')
|
231
269
|
end
|
232
270
|
end
|
233
271
|
|
234
|
-
context
|
235
|
-
it
|
272
|
+
context 'with submit button not associated with any form' do
|
273
|
+
it 'should not error when clicked' do
|
236
274
|
expect { @session.click_button('no_form_button') }.not_to raise_error
|
237
275
|
end
|
238
276
|
end
|
239
277
|
|
240
|
-
context
|
241
|
-
it
|
278
|
+
context 'with alt given on an image button' do
|
279
|
+
it 'should submit the associated form' do
|
242
280
|
@session.click_button('oh hai thar')
|
243
281
|
expect(extract_results(@session)['first_name']).to eq('John')
|
244
282
|
end
|
245
283
|
|
246
|
-
it
|
284
|
+
it 'should work with partial matches', :exact_false do
|
247
285
|
@session.click_button('hai')
|
248
286
|
expect(extract_results(@session)['first_name']).to eq('John')
|
249
287
|
end
|
250
288
|
end
|
251
289
|
|
252
|
-
context
|
253
|
-
it
|
290
|
+
context 'with value given on an image button' do
|
291
|
+
it 'should submit the associated form' do
|
254
292
|
@session.click_button('okay')
|
255
293
|
expect(extract_results(@session)['first_name']).to eq('John')
|
256
294
|
end
|
257
295
|
|
258
|
-
it
|
296
|
+
it 'should work with partial matches', :exact_false do
|
259
297
|
@session.click_button('kay')
|
260
298
|
expect(extract_results(@session)['first_name']).to eq('John')
|
261
299
|
end
|
262
300
|
end
|
263
301
|
|
264
|
-
context
|
265
|
-
it
|
302
|
+
context 'with id given on an image button' do
|
303
|
+
it 'should submit the associated form' do
|
266
304
|
@session.click_button('okay556')
|
267
305
|
expect(extract_results(@session)['first_name']).to eq('John')
|
268
306
|
end
|
269
307
|
end
|
270
308
|
|
271
|
-
context
|
272
|
-
it
|
309
|
+
context 'with title given on an image button' do
|
310
|
+
it 'should submit the associated form' do
|
273
311
|
@session.click_button('Okay 556 Image')
|
274
312
|
expect(extract_results(@session)['first_name']).to eq('John')
|
275
313
|
end
|
276
314
|
|
277
|
-
it
|
315
|
+
it 'should work with partial matches', :exact_false do
|
278
316
|
@session.click_button('Okay 556')
|
279
317
|
expect(extract_results(@session)['first_name']).to eq('John')
|
280
318
|
end
|
281
319
|
end
|
282
320
|
|
283
|
-
context
|
284
|
-
it
|
321
|
+
context 'with text given on a button defined by <button> tag' do
|
322
|
+
it 'should submit the associated form' do
|
285
323
|
@session.click_button('Click me!')
|
286
324
|
expect(extract_results(@session)['first_name']).to eq('John')
|
287
325
|
end
|
288
326
|
|
289
|
-
it
|
327
|
+
it 'should work with partial matches', :exact_false do
|
290
328
|
@session.click_button('Click')
|
291
329
|
expect(extract_results(@session)['first_name']).to eq('John')
|
292
330
|
end
|
293
331
|
end
|
294
332
|
|
295
|
-
context
|
296
|
-
it
|
333
|
+
context 'with id given on a button defined by <button> tag' do
|
334
|
+
it 'should submit the associated form' do
|
297
335
|
@session.click_button('click_me_123')
|
298
336
|
expect(extract_results(@session)['first_name']).to eq('John')
|
299
337
|
end
|
300
338
|
|
301
|
-
it
|
339
|
+
it 'should serialize and send GET forms' do
|
302
340
|
@session.visit('/form')
|
303
341
|
@session.click_button('med')
|
304
|
-
|
305
|
-
expect(
|
306
|
-
expect(
|
342
|
+
results = extract_results(@session)
|
343
|
+
expect(results['middle_name']).to eq('Darren')
|
344
|
+
expect(results['foo']).to be_nil
|
307
345
|
end
|
308
346
|
end
|
309
347
|
|
310
|
-
context
|
311
|
-
it
|
348
|
+
context 'with name given on a button defined by <button> tag' do
|
349
|
+
it 'should submit the associated form when name is locator' do
|
350
|
+
@session.click_button('form[no_value]')
|
351
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
352
|
+
end
|
353
|
+
|
354
|
+
it 'should submit the associated form when name is specific' do
|
355
|
+
@session.click_button(name: 'form[no_value]')
|
356
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
context 'with value given on a button defined by <button> tag' do
|
361
|
+
it 'should submit the associated form' do
|
312
362
|
@session.click_button('click_me')
|
313
363
|
expect(extract_results(@session)['first_name']).to eq('John')
|
314
364
|
end
|
315
365
|
|
316
|
-
it
|
366
|
+
it 'should work with partial matches', :exact_false do
|
317
367
|
@session.click_button('ck_me')
|
318
368
|
expect(extract_results(@session)['first_name']).to eq('John')
|
319
369
|
end
|
320
370
|
end
|
321
371
|
|
322
|
-
context
|
323
|
-
it
|
372
|
+
context 'with title given on a button defined by <button> tag' do
|
373
|
+
it 'should submit the associated form' do
|
324
374
|
@session.click_button('Click Title button')
|
325
375
|
expect(extract_results(@session)['first_name']).to eq('John')
|
326
376
|
end
|
327
377
|
|
328
|
-
it
|
378
|
+
it 'should work with partial matches', :exact_false do
|
329
379
|
@session.click_button('Click Title')
|
330
380
|
expect(extract_results(@session)['first_name']).to eq('John')
|
331
381
|
end
|
332
382
|
end
|
333
383
|
|
334
|
-
context
|
335
|
-
it
|
384
|
+
context 'with descendant image alt given on a button defined by <button> tag' do
|
385
|
+
it 'should submit the associated form' do
|
336
386
|
@session.click_button('A horse eating hay')
|
337
387
|
expect(extract_results(@session)['first_name']).to eq('John')
|
338
388
|
end
|
339
389
|
|
340
|
-
it
|
390
|
+
it 'should work with partial matches', :exact_false do
|
341
391
|
@session.click_button('se eating h')
|
342
392
|
expect(extract_results(@session)['first_name']).to eq('John')
|
343
393
|
end
|
344
394
|
end
|
345
395
|
|
346
396
|
context "with a locator that doesn't exist" do
|
347
|
-
it
|
348
|
-
msg =
|
397
|
+
it 'should raise an error' do
|
398
|
+
msg = /Unable to find button "does not exist"/
|
349
399
|
expect do
|
350
400
|
@session.click_button('does not exist')
|
351
401
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
352
402
|
end
|
353
403
|
end
|
354
404
|
|
355
|
-
context
|
356
|
-
it
|
405
|
+
context 'with formaction attribute on button' do
|
406
|
+
it 'should submit to the formaction attribute' do
|
357
407
|
@session.click_button('Formaction button')
|
358
|
-
|
408
|
+
results = extract_results(@session)
|
359
409
|
expect(@session.current_path).to eq '/form'
|
360
|
-
expect(
|
410
|
+
expect(results['which_form']).to eq 'formaction form'
|
361
411
|
end
|
362
412
|
end
|
363
413
|
|
364
|
-
context
|
365
|
-
it
|
414
|
+
context 'with formmethod attribute on button' do
|
415
|
+
it 'should submit to the formethod attribute' do
|
366
416
|
@session.click_button('Formmethod button')
|
367
|
-
|
417
|
+
results = extract_results(@session)
|
368
418
|
expect(@session.current_path).to eq '/form/get'
|
369
|
-
expect(
|
419
|
+
expect(results['which_form']).to eq 'formaction form'
|
370
420
|
end
|
371
421
|
end
|
372
422
|
|
373
|
-
it
|
423
|
+
it 'should serialize and send valueless buttons that were clicked' do
|
374
424
|
@session.click_button('No Value!')
|
375
|
-
|
376
|
-
expect(
|
425
|
+
results = extract_results(@session)
|
426
|
+
expect(results['no_value']).not_to be_nil
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'should send button in document order' do
|
430
|
+
@session.click_button('outside_button')
|
431
|
+
results = extract_results(@session)
|
432
|
+
expect(results.keys).to eq %w[for_form2 outside_button which_form post_count]
|
377
433
|
end
|
378
434
|
|
379
|
-
it
|
435
|
+
it 'should not send image buttons that were not clicked' do
|
380
436
|
@session.click_button('Click me!')
|
381
|
-
|
382
|
-
expect(
|
437
|
+
results = extract_results(@session)
|
438
|
+
expect(results['okay']).to be_nil
|
383
439
|
end
|
384
440
|
|
385
|
-
it
|
441
|
+
it 'should serialize and send GET forms' do
|
386
442
|
@session.visit('/form')
|
387
443
|
@session.click_button('med')
|
388
|
-
|
389
|
-
expect(
|
390
|
-
expect(
|
444
|
+
results = extract_results(@session)
|
445
|
+
expect(results['middle_name']).to eq('Darren')
|
446
|
+
expect(results['foo']).to be_nil
|
391
447
|
end
|
392
448
|
|
393
|
-
it
|
449
|
+
it 'should follow redirects' do
|
394
450
|
@session.click_button('Go FAR')
|
395
451
|
expect(@session).to have_content('You landed')
|
396
452
|
expect(@session.current_url).to match(%r{/landed$})
|
397
453
|
end
|
398
454
|
|
399
|
-
it
|
455
|
+
it 'should follow temporary redirects that maintain method' do
|
400
456
|
@session.click_button('Go 307')
|
401
457
|
expect(@session).to have_content('You post landed: TWTW')
|
402
458
|
end
|
403
459
|
|
404
|
-
it
|
460
|
+
it 'should follow permanent redirects that maintain method' do
|
405
461
|
@session.click_button('Go 308')
|
406
462
|
expect(@session).to have_content('You post landed: TWTW')
|
407
463
|
end
|
408
464
|
|
409
|
-
it
|
465
|
+
it 'should post pack to the same URL when no action given' do
|
410
466
|
@session.visit('/postback')
|
411
467
|
@session.click_button('With no action')
|
412
468
|
expect(@session).to have_content('Postback')
|
413
469
|
end
|
414
470
|
|
415
|
-
it
|
471
|
+
it 'should post pack to the same URL when blank action given' do
|
416
472
|
@session.visit('/postback')
|
417
473
|
@session.click_button('With blank action')
|
418
474
|
expect(@session).to have_content('Postback')
|
419
475
|
end
|
420
476
|
|
421
|
-
it
|
477
|
+
it 'ignores disabled buttons' do
|
422
478
|
expect do
|
423
479
|
@session.click_button('Disabled button')
|
424
480
|
end.to raise_error(Capybara::ElementNotFound)
|
425
481
|
end
|
426
482
|
|
427
|
-
it
|
483
|
+
it 'should encode complex field names, like array[][value]' do
|
428
484
|
@session.visit('/form')
|
429
485
|
@session.fill_in('address1_city', with: 'Paris')
|
430
486
|
@session.fill_in('address1_street', with: 'CDG')
|
@@ -432,27 +488,27 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
432
488
|
@session.fill_in('address2_city', with: 'Mikolaiv')
|
433
489
|
@session.fill_in('address2_street', with: 'PGS')
|
434
490
|
|
435
|
-
@session.click_button
|
491
|
+
@session.click_button 'awesome'
|
436
492
|
|
437
|
-
addresses = extract_results(@session)[
|
493
|
+
addresses = extract_results(@session)['addresses']
|
438
494
|
expect(addresses.size).to eq(2)
|
439
495
|
|
440
|
-
expect(addresses[0][
|
441
|
-
expect(addresses[0][
|
442
|
-
expect(addresses[0][
|
496
|
+
expect(addresses[0]['street']).to eq('CDG')
|
497
|
+
expect(addresses[0]['city']).to eq('Paris')
|
498
|
+
expect(addresses[0]['country']).to eq('France')
|
443
499
|
|
444
|
-
expect(addresses[1][
|
445
|
-
expect(addresses[1][
|
446
|
-
expect(addresses[1][
|
500
|
+
expect(addresses[1]['street']).to eq('PGS')
|
501
|
+
expect(addresses[1]['city']).to eq('Mikolaiv')
|
502
|
+
expect(addresses[1]['country']).to eq('Ukraine')
|
447
503
|
end
|
448
504
|
|
449
|
-
context
|
450
|
-
it
|
505
|
+
context 'with :exact option' do
|
506
|
+
it 'should accept partial matches when false' do
|
451
507
|
@session.click_button('What an Awesome', exact: false)
|
452
508
|
expect(extract_results(@session)['first_name']).to eq('John')
|
453
509
|
end
|
454
510
|
|
455
|
-
it
|
511
|
+
it 'should not accept partial matches when true' do
|
456
512
|
expect do
|
457
513
|
@session.click_button('What an Awesome', exact: true)
|
458
514
|
end.to raise_error(Capybara::ElementNotFound)
|