capybara 2.15.0 → 3.0.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 +5 -5
- data/History.md +137 -2
- data/README.md +36 -25
- data/lib/capybara/config.rb +11 -57
- data/lib/capybara/cucumber.rb +2 -3
- data/lib/capybara/driver/base.rb +19 -16
- data/lib/capybara/driver/node.rb +5 -4
- data/lib/capybara/dsl.rb +1 -0
- data/lib/capybara/helpers.rb +19 -29
- data/lib/capybara/minitest/spec.rb +16 -13
- data/lib/capybara/minitest.rb +140 -137
- data/lib/capybara/node/actions.rb +68 -89
- data/lib/capybara/node/base.rb +11 -18
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +8 -8
- data/lib/capybara/node/element.rb +32 -42
- data/lib/capybara/node/finders.rb +64 -71
- data/lib/capybara/node/matchers.rb +50 -71
- data/lib/capybara/node/simple.rb +11 -17
- data/lib/capybara/queries/ancestor_query.rb +12 -8
- data/lib/capybara/queries/base_query.rb +22 -18
- data/lib/capybara/queries/current_path_query.rb +12 -25
- data/lib/capybara/queries/match_query.rb +3 -7
- data/lib/capybara/queries/selector_query.rb +100 -96
- data/lib/capybara/queries/sibling_query.rb +5 -5
- data/lib/capybara/queries/text_query.rb +35 -35
- data/lib/capybara/queries/title_query.rb +8 -11
- data/lib/capybara/rack_test/browser.rb +15 -18
- data/lib/capybara/rack_test/css_handlers.rb +6 -4
- data/lib/capybara/rack_test/driver.rb +6 -10
- data/lib/capybara/rack_test/form.rb +52 -39
- data/lib/capybara/rack_test/node.rb +93 -63
- data/lib/capybara/rails.rb +2 -6
- data/lib/capybara/result.rb +22 -22
- data/lib/capybara/rspec/compound.rb +5 -10
- data/lib/capybara/rspec/features.rb +17 -48
- data/lib/capybara/rspec/matcher_proxies.rb +31 -15
- data/lib/capybara/rspec/matchers.rb +116 -58
- data/lib/capybara/rspec.rb +5 -10
- data/lib/capybara/selector/css.rb +6 -11
- data/lib/capybara/selector/filter.rb +1 -17
- data/lib/capybara/selector/filter_set.rb +18 -15
- data/lib/capybara/selector/filters/base.rb +7 -6
- data/lib/capybara/selector/filters/expression_filter.rb +6 -23
- data/lib/capybara/selector/filters/node_filter.rb +2 -12
- data/lib/capybara/selector/selector.rb +28 -34
- data/lib/capybara/selector.rb +129 -117
- data/lib/capybara/selenium/driver.rb +172 -163
- data/lib/capybara/selenium/node.rb +218 -104
- data/lib/capybara/server.rb +3 -2
- data/lib/capybara/session/config.rb +47 -59
- data/lib/capybara/session/matchers.rb +23 -14
- data/lib/capybara/session.rb +175 -229
- data/lib/capybara/spec/fixtures/no_extension +1 -0
- data/lib/capybara/spec/public/test.js +38 -6
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -0
- data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -2
- data/lib/capybara/spec/session/accept_prompt_spec.rb +30 -1
- data/lib/capybara/spec/session/all_spec.rb +31 -18
- data/lib/capybara/spec/session/ancestor_spec.rb +6 -8
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +6 -5
- data/lib/capybara/spec/session/assert_current_path.rb +12 -11
- data/lib/capybara/spec/session/assert_selector.rb +1 -0
- data/lib/capybara/spec/session/assert_text.rb +31 -23
- data/lib/capybara/spec/session/assert_title.rb +13 -3
- data/lib/capybara/spec/session/attach_file_spec.rb +57 -29
- data/lib/capybara/spec/session/body_spec.rb +1 -0
- data/lib/capybara/spec/session/check_spec.rb +7 -6
- data/lib/capybara/spec/session/choose_spec.rb +5 -4
- data/lib/capybara/spec/session/click_button_spec.rb +24 -32
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -7
- data/lib/capybara/spec/session/click_link_spec.rb +8 -7
- data/lib/capybara/spec/session/current_scope_spec.rb +4 -3
- data/lib/capybara/spec/session/current_url_spec.rb +19 -8
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -0
- data/lib/capybara/spec/session/element/assert_match_selector.rb +1 -1
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +1 -1
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +5 -5
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +23 -0
- data/lib/capybara/spec/session/evaluate_script_spec.rb +5 -4
- data/lib/capybara/spec/session/execute_script_spec.rb +4 -3
- data/lib/capybara/spec/session/fill_in_spec.rb +30 -5
- data/lib/capybara/spec/session/find_button_spec.rb +4 -3
- data/lib/capybara/spec/session/find_by_id_spec.rb +2 -1
- data/lib/capybara/spec/session/find_field_spec.rb +9 -15
- data/lib/capybara/spec/session/find_link_spec.rb +6 -5
- data/lib/capybara/spec/session/find_spec.rb +37 -31
- data/lib/capybara/spec/session/first_spec.rb +60 -33
- data/lib/capybara/spec/session/frame/frame_title_spec.rb +23 -0
- data/lib/capybara/spec/session/frame/frame_url_spec.rb +23 -0
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +2 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +9 -16
- data/lib/capybara/spec/session/go_back_spec.rb +1 -0
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -0
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +69 -0
- data/lib/capybara/spec/session/has_button_spec.rb +2 -1
- data/lib/capybara/spec/session/has_css_spec.rb +3 -2
- data/lib/capybara/spec/session/has_current_path_spec.rb +49 -22
- data/lib/capybara/spec/session/has_field_spec.rb +4 -3
- data/lib/capybara/spec/session/has_link_spec.rb +5 -4
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +76 -0
- data/lib/capybara/spec/session/has_select_spec.rb +32 -31
- data/lib/capybara/spec/session/has_selector_spec.rb +5 -4
- data/lib/capybara/spec/session/has_table_spec.rb +2 -1
- data/lib/capybara/spec/session/has_text_spec.rb +9 -13
- data/lib/capybara/spec/session/has_title_spec.rb +1 -0
- data/lib/capybara/spec/session/has_xpath_spec.rb +1 -0
- data/lib/capybara/spec/session/headers.rb +2 -1
- data/lib/capybara/spec/session/html_spec.rb +1 -0
- data/lib/capybara/spec/session/node_spec.rb +107 -58
- data/lib/capybara/spec/session/node_wrapper_spec.rb +36 -0
- data/lib/capybara/spec/session/refresh_spec.rb +6 -2
- data/lib/capybara/spec/session/reset_session_spec.rb +19 -0
- data/lib/capybara/spec/session/response_code.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +6 -11
- data/lib/capybara/spec/session/save_page_spec.rb +1 -17
- data/lib/capybara/spec/session/save_screenshot_spec.rb +3 -3
- data/lib/capybara/spec/session/select_spec.rb +21 -20
- data/lib/capybara/spec/session/selectors_spec.rb +2 -2
- data/lib/capybara/spec/session/sibling_spec.rb +1 -1
- data/lib/capybara/spec/session/text_spec.rb +17 -3
- data/lib/capybara/spec/session/title_spec.rb +11 -1
- data/lib/capybara/spec/session/uncheck_spec.rb +4 -3
- data/lib/capybara/spec/session/unselect_spec.rb +7 -6
- data/lib/capybara/spec/session/visit_spec.rb +64 -3
- data/lib/capybara/spec/session/window/become_closed_spec.rb +2 -1
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +2 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -1
- data/lib/capybara/spec/session/window/window_spec.rb +12 -12
- data/lib/capybara/spec/session/window/windows_spec.rb +2 -3
- data/lib/capybara/spec/session/window/within_window_spec.rb +15 -71
- data/lib/capybara/spec/session/within_spec.rb +1 -0
- data/lib/capybara/spec/spec_helper.rb +36 -18
- data/lib/capybara/spec/test_app.rb +17 -9
- data/lib/capybara/spec/views/form.erb +7 -0
- data/lib/capybara/spec/views/initial_alert.erb +10 -0
- data/lib/capybara/spec/views/with_fixed_header_footer.erb +17 -0
- data/lib/capybara/spec/views/with_hover.erb +5 -0
- data/lib/capybara/spec/views/with_html.erb +27 -1
- data/lib/capybara/spec/views/with_js.erb +11 -0
- data/lib/capybara/spec/views/within_frames.erb +4 -1
- data/lib/capybara/version.rb +2 -1
- data/lib/capybara/window.rb +6 -10
- data/lib/capybara.rb +29 -26
- data/spec/basic_node_spec.rb +1 -0
- data/spec/capybara_spec.rb +16 -69
- data/spec/dsl_spec.rb +5 -13
- data/spec/filter_set_spec.rb +5 -4
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +3 -2
- data/spec/minitest_spec.rb +13 -4
- data/spec/minitest_spec_spec.rb +12 -3
- data/spec/per_session_config_spec.rb +9 -8
- data/spec/rack_test_spec.rb +21 -20
- data/spec/result_spec.rb +17 -16
- data/spec/rspec/features_spec.rb +17 -14
- data/spec/rspec/scenarios_spec.rb +5 -7
- data/spec/rspec/shared_spec_matchers.rb +96 -99
- data/spec/rspec/views_spec.rb +2 -1
- data/spec/rspec_matchers_spec.rb +18 -2
- data/spec/rspec_spec.rb +11 -15
- data/spec/selector_spec.rb +5 -6
- data/spec/selenium_spec_chrome.rb +20 -11
- data/spec/selenium_spec_edge.rb +27 -0
- data/spec/selenium_spec_ie.rb +31 -0
- data/spec/selenium_spec_marionette.rb +38 -12
- data/spec/server_spec.rb +33 -33
- data/spec/session_spec.rb +2 -1
- data/spec/shared_selenium_session.rb +82 -22
- data/spec/spec_helper.rb +3 -6
- metadata +76 -81
- data/lib/capybara/query.rb +0 -7
- data/spec/selenium_spec_firefox.rb +0 -68
@@ -1,27 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec "#attach_file" do
|
3
4
|
before do
|
4
5
|
@test_file_path = File.expand_path('../fixtures/test_file.txt', File.dirname(__FILE__))
|
5
6
|
@another_test_file_path = File.expand_path('../fixtures/another_test_file.txt', File.dirname(__FILE__))
|
6
7
|
@test_jpg_file_path = File.expand_path('../fixtures/capybara.jpg', File.dirname(__FILE__))
|
8
|
+
@no_extension_file_path = File.expand_path('../fixtures/no_extension', File.dirname(__FILE__))
|
7
9
|
@session.visit('/form')
|
8
10
|
end
|
9
11
|
|
10
12
|
context "with normal form" do
|
11
13
|
it "should set a file path by id" do
|
12
|
-
@session.attach_file "form_image", __FILE__
|
14
|
+
@session.attach_file "form_image", with_os_path_separators(__FILE__)
|
13
15
|
@session.click_button('awesome')
|
14
16
|
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
15
17
|
end
|
16
18
|
|
17
19
|
it "should set a file path by label" do
|
18
|
-
@session.attach_file "Image", __FILE__
|
20
|
+
@session.attach_file "Image", with_os_path_separators(__FILE__)
|
19
21
|
@session.click_button('awesome')
|
20
22
|
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
21
23
|
end
|
22
24
|
|
23
25
|
it "casts to string" do
|
24
|
-
@session.attach_file :
|
26
|
+
@session.attach_file :form_image, with_os_path_separators(__FILE__)
|
25
27
|
@session.click_button('awesome')
|
26
28
|
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
27
29
|
end
|
@@ -29,13 +31,13 @@ Capybara::SpecHelper.spec "#attach_file" do
|
|
29
31
|
|
30
32
|
context "with multipart form" do
|
31
33
|
it "should set a file path by id" do
|
32
|
-
@session.attach_file "form_document", @test_file_path
|
34
|
+
@session.attach_file "form_document", with_os_path_separators(@test_file_path)
|
33
35
|
@session.click_button('Upload Single')
|
34
36
|
expect(@session).to have_content(File.read(@test_file_path))
|
35
37
|
end
|
36
38
|
|
37
39
|
it "should set a file path by label" do
|
38
|
-
@session.attach_file "Single Document", @test_file_path
|
40
|
+
@session.attach_file "Single Document", with_os_path_separators(@test_file_path)
|
39
41
|
@session.click_button('Upload Single')
|
40
42
|
expect(@session).to have_content(File.read(@test_file_path))
|
41
43
|
end
|
@@ -46,29 +48,35 @@ Capybara::SpecHelper.spec "#attach_file" do
|
|
46
48
|
end
|
47
49
|
|
48
50
|
it "should send content type text/plain when uploading a text file" do
|
49
|
-
@session.attach_file "Single Document", @test_file_path
|
51
|
+
@session.attach_file "Single Document", with_os_path_separators(@test_file_path)
|
50
52
|
@session.click_button 'Upload Single'
|
51
53
|
expect(@session).to have_content('text/plain')
|
52
54
|
end
|
53
55
|
|
54
56
|
it "should send content type image/jpeg when uploading an image" do
|
55
|
-
@session.attach_file "Single Document", @test_jpg_file_path
|
57
|
+
@session.attach_file "Single Document", with_os_path_separators(@test_jpg_file_path)
|
56
58
|
@session.click_button 'Upload Single'
|
57
59
|
expect(@session).to have_content('image/jpeg')
|
58
60
|
end
|
59
61
|
|
62
|
+
it "should not break when uploading a file without extension" do
|
63
|
+
@session.attach_file "Single Document", with_os_path_separators(@no_extension_file_path)
|
64
|
+
@session.click_button 'Upload Single'
|
65
|
+
expect(@session).to have_content(File.read(@no_extension_file_path))
|
66
|
+
end
|
67
|
+
|
60
68
|
it "should not break when using HTML5 multiple file input" do
|
61
|
-
@session.attach_file "Multiple Documents", @test_file_path
|
69
|
+
@session.attach_file "Multiple Documents", with_os_path_separators(@test_file_path)
|
62
70
|
@session.click_button('Upload Multiple')
|
63
71
|
expect(@session).to have_content(File.read(@test_file_path))
|
64
|
-
expect(@session.body).to include("1 | ")#number of files
|
72
|
+
expect(@session.body).to include("1 | ") # number of files
|
65
73
|
end
|
66
74
|
|
67
|
-
it
|
68
|
-
|
69
|
-
|
75
|
+
it "should not break when using HTML5 multiple file input uploading multiple files" do
|
76
|
+
@session.attach_file("Multiple Documents",
|
77
|
+
[@test_file_path, @another_test_file_path].map { |f| with_os_path_separators(f) })
|
70
78
|
@session.click_button('Upload Multiple')
|
71
|
-
expect(@session.body).to include("2 | ")#number of files
|
79
|
+
expect(@session.body).to include("2 | ") # number of files
|
72
80
|
expect(@session.body).to include(File.read(@test_file_path))
|
73
81
|
expect(@session.body).to include(File.read(@another_test_file_path))
|
74
82
|
end
|
@@ -77,13 +85,23 @@ Capybara::SpecHelper.spec "#attach_file" do
|
|
77
85
|
@session.click_button('Upload Empty Multiple')
|
78
86
|
expect(@session).to have_content("Successfully ignored empty file field")
|
79
87
|
end
|
88
|
+
|
89
|
+
it "should not append files to already attached" do
|
90
|
+
@session.attach_file "Multiple Documents", with_os_path_separators(@test_file_path)
|
91
|
+
@session.attach_file("Multiple Documents",
|
92
|
+
[@test_file_path, @another_test_file_path].map { |f| with_os_path_separators(f) })
|
93
|
+
@session.click_button('Upload Multiple')
|
94
|
+
expect(@session.body).to include("2 | ") # number of files
|
95
|
+
expect(@session.body).to include(File.read(@test_file_path))
|
96
|
+
expect(@session.body).to include(File.read(@another_test_file_path))
|
97
|
+
end
|
80
98
|
end
|
81
99
|
|
82
100
|
context "with a locator that doesn't exist" do
|
83
101
|
it "should raise an error" do
|
84
102
|
msg = "Unable to find visible file field \"does not exist\" that is not disabled"
|
85
103
|
expect do
|
86
|
-
@session.attach_file('does not exist', @test_file_path)
|
104
|
+
@session.attach_file('does not exist', with_os_path_separators(@test_file_path))
|
87
105
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
88
106
|
end
|
89
107
|
end
|
@@ -96,45 +114,55 @@ Capybara::SpecHelper.spec "#attach_file" do
|
|
96
114
|
|
97
115
|
context "with :exact option" do
|
98
116
|
it "should set a file path by partial label when false" do
|
99
|
-
@session.attach_file "Imag", __FILE__, exact:
|
117
|
+
@session.attach_file "Imag", with_os_path_separators(__FILE__), exact: false
|
100
118
|
@session.click_button('awesome')
|
101
119
|
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
102
120
|
end
|
103
121
|
|
104
|
-
it "not allow partial matches when true" do
|
122
|
+
it "should not allow partial matches when true" do
|
105
123
|
expect do
|
106
|
-
@session.attach_file "Imag", __FILE__, exact:
|
124
|
+
@session.attach_file "Imag", with_os_path_separators(__FILE__), exact: true
|
107
125
|
end.to raise_error(Capybara::ElementNotFound)
|
108
126
|
end
|
109
127
|
end
|
110
128
|
|
111
|
-
context "with :make_visible option", requires: [
|
129
|
+
context "with :make_visible option", requires: %i[js es_args] do
|
112
130
|
it "applies a default style change when true" do
|
113
131
|
@session.visit('/with_js')
|
114
|
-
expect
|
115
|
-
|
116
|
-
|
117
|
-
|
132
|
+
expect do
|
133
|
+
@session.attach_file("hidden_file", with_os_path_separators(__FILE__))
|
134
|
+
end.to raise_error Capybara::ElementNotFound
|
135
|
+
expect do
|
136
|
+
@session.attach_file("hidden_file", with_os_path_separators(__FILE__), make_visible: true)
|
137
|
+
end.not_to raise_error
|
118
138
|
end
|
119
139
|
|
120
140
|
it "accepts a hash of styles to be applied" do
|
121
141
|
@session.visit('/with_js')
|
122
|
-
expect
|
123
|
-
@session.attach_file("hidden_file",
|
124
|
-
|
142
|
+
expect do
|
143
|
+
@session.attach_file("hidden_file",
|
144
|
+
with_os_path_separators(__FILE__),
|
145
|
+
make_visible: { opacity: 1, display: 'block' })
|
146
|
+
end.not_to raise_error
|
125
147
|
end
|
126
148
|
|
127
149
|
it "raises an error when the file input is not made visible" do
|
128
150
|
@session.visit('/with_js')
|
129
|
-
expect
|
130
|
-
@session.attach_file("hidden_file", __FILE__, make_visible: { color: 'red' })
|
131
|
-
|
151
|
+
expect do
|
152
|
+
@session.attach_file("hidden_file", with_os_path_separators(__FILE__), make_visible: { color: 'red' })
|
153
|
+
end.to raise_error(Capybara::ExpectationNotMet)
|
132
154
|
end
|
133
155
|
|
134
156
|
it "resets the style when done" do
|
135
157
|
@session.visit('/with_js')
|
136
|
-
@session.attach_file("hidden_file", __FILE__, make_visible: true)
|
158
|
+
@session.attach_file("hidden_file", with_os_path_separators(__FILE__), make_visible: true)
|
137
159
|
expect(@session.evaluate_script("arguments[0].style.display", @session.find(:css, '#hidden_file', visible: :all))).to eq 'none'
|
138
160
|
end
|
139
161
|
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
def with_os_path_separators(path)
|
166
|
+
Gem.win_platform? ? path.to_s.tr('/', '\\') : path.to_s
|
167
|
+
end
|
140
168
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec "#check" do
|
3
4
|
before do
|
4
5
|
@session.visit('/form')
|
@@ -18,7 +19,7 @@ Capybara::SpecHelper.spec "#check" do
|
|
18
19
|
it "should trigger associated events", requires: [:js] do
|
19
20
|
@session.visit('/with_js')
|
20
21
|
@session.check('checkbox_with_event')
|
21
|
-
expect(@session).to have_css('#checkbox_event_triggered')
|
22
|
+
expect(@session).to have_css('#checkbox_event_triggered')
|
22
23
|
end
|
23
24
|
|
24
25
|
describe "checking" do
|
@@ -62,7 +63,7 @@ Capybara::SpecHelper.spec "#check" do
|
|
62
63
|
end
|
63
64
|
|
64
65
|
it "casts to string" do
|
65
|
-
@session.check(:
|
66
|
+
@session.check(:form_pets_cat)
|
66
67
|
@session.click_button('awesome')
|
67
68
|
expect(extract_results(@session)['pets']).to include('dog', 'cat', 'hamster')
|
68
69
|
end
|
@@ -86,14 +87,14 @@ Capybara::SpecHelper.spec "#check" do
|
|
86
87
|
|
87
88
|
context "with :exact option" do
|
88
89
|
it "should accept partial matches when false" do
|
89
|
-
@session.check('Ham', exact:
|
90
|
+
@session.check('Ham', exact: false)
|
90
91
|
@session.click_button('awesome')
|
91
92
|
expect(extract_results(@session)['pets']).to include('hamster')
|
92
93
|
end
|
93
94
|
|
94
95
|
it "should not accept partial matches when true" do
|
95
96
|
expect do
|
96
|
-
@session.check('Ham', exact:
|
97
|
+
@session.check('Ham', exact: true)
|
97
98
|
end.to raise_error(Capybara::ElementNotFound)
|
98
99
|
end
|
99
100
|
end
|
@@ -146,7 +147,7 @@ Capybara::SpecHelper.spec "#check" do
|
|
146
147
|
end
|
147
148
|
|
148
149
|
it "should raise error if not allowed to click label" do
|
149
|
-
expect{@session.check('form_cars_mclaren', allow_label_click: false)}.to raise_error(Capybara::ElementNotFound, 'Unable to find visible checkbox "form_cars_mclaren" that is not disabled')
|
150
|
+
expect { @session.check('form_cars_mclaren', allow_label_click: false) }.to raise_error(Capybara::ElementNotFound, 'Unable to find visible checkbox "form_cars_mclaren" that is not disabled')
|
150
151
|
end
|
151
152
|
end
|
152
153
|
|
@@ -158,7 +159,7 @@ Capybara::SpecHelper.spec "#check" do
|
|
158
159
|
end
|
159
160
|
|
160
161
|
it "should raise error if checkbox not visible" do
|
161
|
-
expect{@session.check('form_cars_mclaren')}.to raise_error(Capybara::ElementNotFound, 'Unable to find visible checkbox "form_cars_mclaren" that is not disabled')
|
162
|
+
expect { @session.check('form_cars_mclaren') }.to raise_error(Capybara::ElementNotFound, 'Unable to find visible checkbox "form_cars_mclaren" that is not disabled')
|
162
163
|
end
|
163
164
|
|
164
165
|
context "with allow_label_click == true" do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec "#choose" do
|
3
4
|
before do
|
4
5
|
@session.visit('/form')
|
@@ -18,7 +19,7 @@ Capybara::SpecHelper.spec "#choose" do
|
|
18
19
|
|
19
20
|
it "casts to string" do
|
20
21
|
@session.choose("Both")
|
21
|
-
@session.click_button(:
|
22
|
+
@session.click_button(:awesome)
|
22
23
|
expect(extract_results(@session)['gender']).to eq('both')
|
23
24
|
end
|
24
25
|
|
@@ -41,14 +42,14 @@ Capybara::SpecHelper.spec "#choose" do
|
|
41
42
|
|
42
43
|
context "with :exact option" do
|
43
44
|
it "should accept partial matches when false" do
|
44
|
-
@session.choose("Mal", exact:
|
45
|
+
@session.choose("Mal", exact: false)
|
45
46
|
@session.click_button('awesome')
|
46
47
|
expect(extract_results(@session)['gender']).to eq('male')
|
47
48
|
end
|
48
49
|
|
49
50
|
it "should not accept partial matches when true" do
|
50
51
|
expect do
|
51
|
-
@session.choose("Mal", exact:
|
52
|
+
@session.choose("Mal", exact: true)
|
52
53
|
end.to raise_error(Capybara::ElementNotFound)
|
53
54
|
end
|
54
55
|
end
|
@@ -82,7 +83,7 @@ Capybara::SpecHelper.spec "#choose" do
|
|
82
83
|
end
|
83
84
|
|
84
85
|
it "should raise error if not allowed to click label" do
|
85
|
-
expect{@session.choose("party_democrat", allow_label_click: false)}.to raise_error(Capybara::ElementNotFound, 'Unable to find visible radio button "party_democrat" that is not disabled')
|
86
|
+
expect { @session.choose("party_democrat", allow_label_click: false) }.to raise_error(Capybara::ElementNotFound, 'Unable to find visible radio button "party_democrat" that is not disabled')
|
86
87
|
end
|
87
88
|
end
|
88
89
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#click_button' do
|
3
4
|
before do
|
4
5
|
@session.visit('/form')
|
@@ -151,31 +152,24 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
151
152
|
end
|
152
153
|
end
|
153
154
|
|
154
|
-
context "
|
155
|
-
it "should submit
|
155
|
+
context "input type=submit button" do
|
156
|
+
it "should submit by button id" do
|
156
157
|
@session.click_button('awe123')
|
157
158
|
expect(extract_results(@session)['first_name']).to eq('John')
|
158
159
|
end
|
159
160
|
|
160
|
-
it "should
|
161
|
-
@session.click_button('Go')
|
162
|
-
expect(@session).to have_content('You landed')
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context "with title given on a submit button" do
|
167
|
-
it "should submit the associated form" do
|
161
|
+
it "should submit by button title" do
|
168
162
|
@session.click_button('What an Awesome Button')
|
169
163
|
expect(extract_results(@session)['first_name']).to eq('John')
|
170
164
|
end
|
171
165
|
|
172
|
-
it "should
|
166
|
+
it "should submit by partial title", :exact_false do
|
173
167
|
@session.click_button('What an Awesome')
|
174
168
|
expect(extract_results(@session)['first_name']).to eq('John')
|
175
169
|
end
|
176
170
|
end
|
177
171
|
|
178
|
-
context "with fields associated with the form using the form attribute" do
|
172
|
+
context "with fields associated with the form using the form attribute", requires: [:form_attribute] do
|
179
173
|
before do
|
180
174
|
@session.click_button('submit_form1')
|
181
175
|
@results = extract_results(@session)
|
@@ -198,8 +192,7 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
198
192
|
end
|
199
193
|
end
|
200
194
|
|
201
|
-
|
202
|
-
context "with submit button outside the form defined by <button> tag" do
|
195
|
+
context "with submit button outside the form defined by <button> tag", requires: [:form_attribute] do
|
203
196
|
before do
|
204
197
|
@session.click_button('outside_button')
|
205
198
|
@results = extract_results(@session)
|
@@ -215,7 +208,7 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
215
208
|
end
|
216
209
|
end
|
217
210
|
|
218
|
-
context "with submit button outside the form defined by <input type='submit'> tag" do
|
211
|
+
context "with submit button outside the form defined by <input type='submit'> tag", requires: [:form_attribute] do
|
219
212
|
before do
|
220
213
|
@session.click_button('outside_submit')
|
221
214
|
@results = extract_results(@session)
|
@@ -231,7 +224,7 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
231
224
|
end
|
232
225
|
end
|
233
226
|
|
234
|
-
context "with submit button for form1 located within form2" do
|
227
|
+
context "with submit button for form1 located within form2", requires: [:form_attribute] do
|
235
228
|
it "should submit the form associated with the button" do
|
236
229
|
@session.click_button('other_form_button')
|
237
230
|
expect(extract_results(@session)['which_form']).to eq("form1")
|
@@ -250,20 +243,19 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
250
243
|
expect(extract_results(@session)['first_name']).to eq('John')
|
251
244
|
end
|
252
245
|
|
253
|
-
it "should work with partial matches" do
|
246
|
+
it "should work with partial matches", :exact_false do
|
254
247
|
@session.click_button('hai')
|
255
248
|
expect(extract_results(@session)['first_name']).to eq('John')
|
256
249
|
end
|
257
250
|
end
|
258
251
|
|
259
|
-
|
260
252
|
context "with value given on an image button" do
|
261
253
|
it "should submit the associated form" do
|
262
254
|
@session.click_button('okay')
|
263
255
|
expect(extract_results(@session)['first_name']).to eq('John')
|
264
256
|
end
|
265
257
|
|
266
|
-
it "should work with partial matches" do
|
258
|
+
it "should work with partial matches", :exact_false do
|
267
259
|
@session.click_button('kay')
|
268
260
|
expect(extract_results(@session)['first_name']).to eq('John')
|
269
261
|
end
|
@@ -282,7 +274,7 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
282
274
|
expect(extract_results(@session)['first_name']).to eq('John')
|
283
275
|
end
|
284
276
|
|
285
|
-
it "should work with partial matches" do
|
277
|
+
it "should work with partial matches", :exact_false do
|
286
278
|
@session.click_button('Okay 556')
|
287
279
|
expect(extract_results(@session)['first_name']).to eq('John')
|
288
280
|
end
|
@@ -290,17 +282,17 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
290
282
|
|
291
283
|
context "with text given on a button defined by <button> tag" do
|
292
284
|
it "should submit the associated form" do
|
293
|
-
@session.click_button('Click me')
|
285
|
+
@session.click_button('Click me!')
|
294
286
|
expect(extract_results(@session)['first_name']).to eq('John')
|
295
287
|
end
|
296
288
|
|
297
|
-
it "should work with partial matches" do
|
289
|
+
it "should work with partial matches", :exact_false do
|
298
290
|
@session.click_button('Click')
|
299
291
|
expect(extract_results(@session)['first_name']).to eq('John')
|
300
292
|
end
|
301
293
|
end
|
302
294
|
|
303
|
-
|
295
|
+
context "with id given on a button defined by <button> tag" do
|
304
296
|
it "should submit the associated form" do
|
305
297
|
@session.click_button('click_me_123')
|
306
298
|
expect(extract_results(@session)['first_name']).to eq('John')
|
@@ -315,13 +307,13 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
315
307
|
end
|
316
308
|
end
|
317
309
|
|
318
|
-
|
310
|
+
context "with value given on a button defined by <button> tag" do
|
319
311
|
it "should submit the associated form" do
|
320
312
|
@session.click_button('click_me')
|
321
313
|
expect(extract_results(@session)['first_name']).to eq('John')
|
322
314
|
end
|
323
315
|
|
324
|
-
it "should work with partial matches" do
|
316
|
+
it "should work with partial matches", :exact_false do
|
325
317
|
@session.click_button('ck_me')
|
326
318
|
expect(extract_results(@session)['first_name']).to eq('John')
|
327
319
|
end
|
@@ -333,7 +325,7 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
333
325
|
expect(extract_results(@session)['first_name']).to eq('John')
|
334
326
|
end
|
335
327
|
|
336
|
-
it "should work with partial matches" do
|
328
|
+
it "should work with partial matches", :exact_false do
|
337
329
|
@session.click_button('Click Title')
|
338
330
|
expect(extract_results(@session)['first_name']).to eq('John')
|
339
331
|
end
|
@@ -345,7 +337,7 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
345
337
|
expect(extract_results(@session)['first_name']).to eq('John')
|
346
338
|
end
|
347
339
|
|
348
|
-
it "should work with partial matches" do
|
340
|
+
it "should work with partial matches", :exact_false do
|
349
341
|
@session.click_button('se eating h')
|
350
342
|
expect(extract_results(@session)['first_name']).to eq('John')
|
351
343
|
end
|
@@ -424,15 +416,15 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
424
416
|
|
425
417
|
it "should encode complex field names, like array[][value]" do
|
426
418
|
@session.visit('/form')
|
427
|
-
@session.fill_in('address1_city', :
|
428
|
-
@session.fill_in('address1_street', :
|
419
|
+
@session.fill_in('address1_city', with: 'Paris')
|
420
|
+
@session.fill_in('address1_street', with: 'CDG')
|
429
421
|
|
430
422
|
@session.fill_in('address2_city', with: 'Mikolaiv')
|
431
423
|
@session.fill_in('address2_street', with: 'PGS')
|
432
424
|
|
433
425
|
@session.click_button "awesome"
|
434
426
|
|
435
|
-
addresses=extract_results(@session)["addresses"]
|
427
|
+
addresses = extract_results(@session)["addresses"]
|
436
428
|
expect(addresses.size).to eq(2)
|
437
429
|
|
438
430
|
expect(addresses[0]["street"]).to eq('CDG')
|
@@ -446,13 +438,13 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
446
438
|
|
447
439
|
context "with :exact option" do
|
448
440
|
it "should accept partial matches when false" do
|
449
|
-
@session.click_button('What an Awesome', exact:
|
441
|
+
@session.click_button('What an Awesome', exact: false)
|
450
442
|
expect(extract_results(@session)['first_name']).to eq('John')
|
451
443
|
end
|
452
444
|
|
453
445
|
it "should not accept partial matches when true" do
|
454
446
|
expect do
|
455
|
-
@session.click_button('What an Awesome', exact:
|
447
|
+
@session.click_button('What an Awesome', exact: true)
|
456
448
|
end.to raise_error(Capybara::ElementNotFound)
|
457
449
|
end
|
458
450
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#click_link_or_button' do
|
3
4
|
it "should click on a link" do
|
4
5
|
@session.visit('/with_html')
|
@@ -32,31 +33,31 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
|
|
32
33
|
|
33
34
|
it "casts to string" do
|
34
35
|
@session.visit('/form')
|
35
|
-
@session.click_link_or_button(:
|
36
|
+
@session.click_link_or_button(:awe123)
|
36
37
|
expect(extract_results(@session)['first_name']).to eq('John')
|
37
38
|
end
|
38
39
|
|
39
40
|
context "with :exact option" do
|
40
|
-
context "when `
|
41
|
+
context "when `false`" do
|
41
42
|
it "clicks on approximately matching link" do
|
42
43
|
@session.visit('/with_html')
|
43
|
-
@session.click_link_or_button('abore', exact:
|
44
|
+
@session.click_link_or_button('abore', exact: false)
|
44
45
|
expect(@session).to have_content('Bar')
|
45
46
|
end
|
46
47
|
|
47
48
|
it "clicks on approximately matching button" do
|
48
49
|
@session.visit('/form')
|
49
|
-
@session.click_link_or_button('awe')
|
50
|
+
@session.click_link_or_button('awe', exact: false)
|
50
51
|
expect(extract_results(@session)['first_name']).to eq('John')
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
|
-
context "when `
|
55
|
+
context "when `true`" do
|
55
56
|
it "does not click on link which matches approximately" do
|
56
57
|
@session.visit('/with_html')
|
57
58
|
msg = "Unable to find visible link or button \"abore\""
|
58
59
|
expect do
|
59
|
-
@session.click_link_or_button('abore', exact:
|
60
|
+
@session.click_link_or_button('abore', exact: true)
|
60
61
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
61
62
|
end
|
62
63
|
|
@@ -65,7 +66,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
|
|
65
66
|
msg = "Unable to find visible link or button \"awe\""
|
66
67
|
|
67
68
|
expect do
|
68
|
-
@session.click_link_or_button('awe', exact:
|
69
|
+
@session.click_link_or_button('awe', exact: true)
|
69
70
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
70
71
|
end
|
71
72
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#click_link' do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_html')
|
@@ -11,7 +12,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
11
12
|
end
|
12
13
|
|
13
14
|
it "casts to string" do
|
14
|
-
@session.click_link(:
|
15
|
+
@session.click_link(:foo)
|
15
16
|
expect(@session).to have_content('Another World')
|
16
17
|
end
|
17
18
|
|
@@ -35,7 +36,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
35
36
|
expect(@session).to have_content('Bar')
|
36
37
|
end
|
37
38
|
|
38
|
-
it "should accept partial matches" do
|
39
|
+
it "should accept partial matches", :exact_false do
|
39
40
|
@session.click_link('abo')
|
40
41
|
expect(@session).to have_content('Bar')
|
41
42
|
end
|
@@ -47,7 +48,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
47
48
|
expect(@session).to have_content('Bar')
|
48
49
|
end
|
49
50
|
|
50
|
-
it "should accept partial matches" do
|
51
|
+
it "should accept partial matches", :exact_false do
|
51
52
|
@session.click_link('some titl')
|
52
53
|
expect(@session).to have_content('Bar')
|
53
54
|
end
|
@@ -59,7 +60,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
59
60
|
expect(@session).to have_content('Bar')
|
60
61
|
end
|
61
62
|
|
62
|
-
it "should accept partial matches" do
|
63
|
+
it "should accept partial matches", :exact_false do
|
63
64
|
@session.click_link('some imag')
|
64
65
|
expect(@session).to have_content('Bar')
|
65
66
|
end
|
@@ -85,7 +86,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
88
|
-
context "with a regex :href option given"
|
89
|
+
context "with a regex :href option given" do
|
89
90
|
it "should find a link matching an all-matching regex pattern" do
|
90
91
|
@session.click_link('labore', href: /.+/)
|
91
92
|
expect(@session).to have_content('Bar')
|
@@ -180,13 +181,13 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
180
181
|
|
181
182
|
context "with :exact option" do
|
182
183
|
it "should accept partial matches when false" do
|
183
|
-
@session.click_link('abo', exact:
|
184
|
+
@session.click_link('abo', exact: false)
|
184
185
|
expect(@session).to have_content('Bar')
|
185
186
|
end
|
186
187
|
|
187
188
|
it "should not accept partial matches when true" do
|
188
189
|
expect do
|
189
|
-
@session.click_link('abo', exact:
|
190
|
+
@session.click_link('abo', exact: true)
|
190
191
|
end.to raise_error(Capybara::ElementNotFound)
|
191
192
|
end
|
192
193
|
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#current_scope' do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_scope')
|
5
6
|
end
|
6
|
-
|
7
|
+
|
7
8
|
context "when not in a #within block" do
|
8
9
|
it "should return the document" do
|
9
10
|
expect(@session.current_scope).to be_kind_of Capybara::Node::Document
|
10
11
|
end
|
11
12
|
end
|
12
|
-
|
13
|
+
|
13
14
|
context "when in a #within block" do
|
14
15
|
it "should return the element in scope" do
|
15
16
|
@session.within(:css, "#simple_first_name") do
|
@@ -17,7 +18,7 @@ Capybara::SpecHelper.spec '#current_scope' do
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
context "when in a nested #within block" do
|
22
23
|
it "should return the element in scope" do
|
23
24
|
@session.within("//div[@id='for_bar']") do
|