capybara 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +23 -0
- data/README.md +37 -30
- data/lib/capybara/node/actions.rb +18 -15
- data/lib/capybara/node/base.rb +2 -2
- data/lib/capybara/node/element.rb +1 -1
- data/lib/capybara/node/finders.rb +37 -32
- data/lib/capybara/node/matchers.rb +187 -171
- data/lib/capybara/queries/match_query.rb +1 -3
- data/lib/capybara/queries/selector_query.rb +48 -19
- data/lib/capybara/rack_test/driver.rb +3 -3
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/rspec/features.rb +1 -1
- data/lib/capybara/rspec/matchers.rb +31 -22
- data/lib/capybara/selector/css.rb +30 -0
- data/lib/capybara/selector/selector.rb +24 -1
- data/lib/capybara/selector.rb +22 -23
- data/lib/capybara/session.rb +4 -4
- data/lib/capybara/spec/session/accept_alert_spec.rb +4 -4
- data/lib/capybara/spec/session/accept_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/accept_prompt_spec.rb +5 -5
- data/lib/capybara/spec/session/all_spec.rb +27 -27
- data/lib/capybara/spec/session/assert_current_path.rb +2 -2
- data/lib/capybara/spec/session/assert_selector.rb +28 -28
- data/lib/capybara/spec/session/assert_text.rb +20 -20
- data/lib/capybara/spec/session/assert_title.rb +2 -2
- data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
- data/lib/capybara/spec/session/check_spec.rb +19 -10
- data/lib/capybara/spec/session/choose_spec.rb +4 -4
- data/lib/capybara/spec/session/click_button_spec.rb +18 -5
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +6 -6
- data/lib/capybara/spec/session/click_link_spec.rb +13 -13
- data/lib/capybara/spec/session/current_url_spec.rb +2 -2
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -1
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +21 -8
- data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
- data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
- data/lib/capybara/spec/session/fill_in_spec.rb +30 -30
- data/lib/capybara/spec/session/find_button_spec.rb +5 -5
- data/lib/capybara/spec/session/find_by_id_spec.rb +2 -2
- data/lib/capybara/spec/session/find_field_spec.rb +11 -7
- data/lib/capybara/spec/session/find_link_spec.rb +2 -2
- data/lib/capybara/spec/session/find_spec.rb +57 -48
- data/lib/capybara/spec/session/first_spec.rb +9 -9
- 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_button_spec.rb +12 -12
- data/lib/capybara/spec/session/has_css_spec.rb +73 -73
- data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
- data/lib/capybara/spec/session/has_field_spec.rb +78 -68
- data/lib/capybara/spec/session/has_link_spec.rb +8 -8
- data/lib/capybara/spec/session/has_select_spec.rb +70 -61
- data/lib/capybara/spec/session/has_selector_spec.rb +28 -28
- data/lib/capybara/spec/session/has_text_spec.rb +6 -6
- data/lib/capybara/spec/session/has_title_spec.rb +2 -2
- data/lib/capybara/spec/session/has_xpath_spec.rb +26 -26
- data/lib/capybara/spec/session/headers.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +3 -3
- data/lib/capybara/spec/session/node_spec.rb +15 -15
- data/lib/capybara/spec/session/reset_session_spec.rb +4 -4
- data/lib/capybara/spec/session/response_code.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +3 -3
- data/lib/capybara/spec/session/screenshot_spec.rb +1 -1
- data/lib/capybara/spec/session/select_spec.rb +30 -30
- data/lib/capybara/spec/session/selectors_spec.rb +6 -2
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +14 -14
- data/lib/capybara/spec/session/visit_spec.rb +2 -2
- data/lib/capybara/spec/session/within_frame_spec.rb +2 -2
- data/lib/capybara/spec/session/within_spec.rb +6 -6
- data/lib/capybara/spec/spec_helper.rb +1 -1
- data/lib/capybara/spec/test_app.rb +1 -1
- data/lib/capybara/spec/views/form.erb +6 -3
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara.rb +2 -2
- data/spec/basic_node_spec.rb +5 -5
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +1 -1
- data/spec/rack_test_spec.rb +7 -7
- data/spec/rspec/matchers_spec.rb +6 -6
- data/spec/rspec_spec.rb +1 -1
- data/spec/selector_spec.rb +94 -3
- data/spec/selenium_firefox_spec.rb +1 -1
- data/spec/selenium_spec_chrome.rb +1 -1
- data/spec/shared_selenium_session.rb +10 -10
- metadata +3 -2
|
@@ -4,7 +4,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
|
4
4
|
@session.visit('/with_html')
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
it "should wait for asynchronous load", :
|
|
7
|
+
it "should wait for asynchronous load", requires: [:js] do
|
|
8
8
|
@session.visit('/with_js')
|
|
9
9
|
@session.click_link('Click me')
|
|
10
10
|
@session.click_link('Has been clicked')
|
|
@@ -15,7 +15,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
|
15
15
|
expect(@session).to have_content('Another World')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
it "raises any errors caught inside the server", :
|
|
18
|
+
it "raises any errors caught inside the server", requires: [:server] do
|
|
19
19
|
quietly { @session.visit("/error") }
|
|
20
20
|
expect do
|
|
21
21
|
@session.click_link('foo')
|
|
@@ -76,34 +76,34 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
|
76
76
|
|
|
77
77
|
context "with :href option given" do
|
|
78
78
|
it "should find links with valid href" do
|
|
79
|
-
@session.click_link('labore', :
|
|
79
|
+
@session.click_link('labore', href: '/with_simple_html')
|
|
80
80
|
expect(@session).to have_content('Bar')
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it "should raise error if link wasn't found" do
|
|
84
|
-
expect { @session.click_link('labore', :
|
|
84
|
+
expect { @session.click_link('labore', href: 'invalid_href') }.to raise_error(Capybara::ElementNotFound)
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
context "with a regex :href option given" do
|
|
89
89
|
it "should find a link matching an all-matching regex pattern" do
|
|
90
|
-
@session.click_link('labore', :
|
|
90
|
+
@session.click_link('labore', href: /.+/)
|
|
91
91
|
expect(@session).to have_content('Bar')
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
it "should find a link matching an exact regex pattern" do
|
|
95
|
-
@session.click_link('labore', :
|
|
95
|
+
@session.click_link('labore', href: /\/with_simple_html/)
|
|
96
96
|
expect(@session).to have_content('Bar')
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "should find a link matching a partial regex pattern" do
|
|
100
|
-
@session.click_link('labore', :
|
|
100
|
+
@session.click_link('labore', href: /\/with_simple/)
|
|
101
101
|
expect(@session).to have_content('Bar')
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
it "should raise an error if no link's href matched the pattern" do
|
|
105
|
-
expect { @session.click_link('labore', :
|
|
106
|
-
expect { @session.click_link('labore', :
|
|
105
|
+
expect { @session.click_link('labore', href: /invalid_pattern/) }.to raise_error(Capybara::ElementNotFound)
|
|
106
|
+
expect { @session.click_link('labore', href: /.+d+/) }.to raise_error(Capybara::ElementNotFound)
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -135,7 +135,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it "should do nothing on anchor links" do
|
|
138
|
-
@session.fill_in("test_field", :
|
|
138
|
+
@session.fill_in("test_field", with: 'blah')
|
|
139
139
|
@session.click_link('Normal Anchor')
|
|
140
140
|
expect(@session.find_field("test_field").value).to eq('blah')
|
|
141
141
|
@session.click_link('Blank Anchor')
|
|
@@ -145,7 +145,7 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
it "should do nothing on URL+anchor links for the same page" do
|
|
148
|
-
@session.fill_in("test_field", :
|
|
148
|
+
@session.fill_in("test_field", with: 'blah')
|
|
149
149
|
@session.click_link('Anchor on same page')
|
|
150
150
|
expect(@session.find_field("test_field").value).to eq('blah')
|
|
151
151
|
end
|
|
@@ -169,13 +169,13 @@ Capybara::SpecHelper.spec '#click_link' do
|
|
|
169
169
|
|
|
170
170
|
context "with :exact option" do
|
|
171
171
|
it "should accept partial matches when false" do
|
|
172
|
-
@session.click_link('abo', :
|
|
172
|
+
@session.click_link('abo', exact: false)
|
|
173
173
|
expect(@session).to have_content('Bar')
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
it "should not accept partial matches when true" do
|
|
177
177
|
expect do
|
|
178
|
-
@session.click_link('abo', :
|
|
178
|
+
@session.click_link('abo', exact: true)
|
|
179
179
|
end.to raise_error(Capybara::ElementNotFound)
|
|
180
180
|
end
|
|
181
181
|
end
|
|
@@ -85,13 +85,13 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
|
|
|
85
85
|
should_be_on 0, "/landed"
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
it "is affected by pushState", :
|
|
88
|
+
it "is affected by pushState", requires: [:js] do
|
|
89
89
|
@session.visit("/with_js")
|
|
90
90
|
@session.execute_script("window.history.pushState({}, '', '/pushed')")
|
|
91
91
|
expect(@session.current_path).to eq("/pushed")
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
it "is affected by replaceState", :
|
|
94
|
+
it "is affected by replaceState", requires: [:js] do
|
|
95
95
|
@session.visit("/with_js")
|
|
96
96
|
@session.execute_script("window.history.replaceState({}, '', '/replaced')")
|
|
97
97
|
expect(@session.current_path).to eq("/replaced")
|
|
@@ -24,8 +24,8 @@ Capybara::SpecHelper.spec '#match_selector?' do
|
|
|
24
24
|
|
|
25
25
|
context "with text" do
|
|
26
26
|
it "should discard all matches where the given string is not contained" do
|
|
27
|
-
expect(@element).to match_selector("//span", :
|
|
28
|
-
expect(@element).not_to match_selector("//span", :
|
|
27
|
+
expect(@element).to match_selector("//span", text: "42")
|
|
28
|
+
expect(@element).not_to match_selector("//span", text: "Doesnotexist")
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -42,6 +42,19 @@ Capybara::SpecHelper.spec '#match_selector?' do
|
|
|
42
42
|
expect(@element.matches_xpath?("//span", text: '42')).to be true
|
|
43
43
|
expect(@element.matches_xpath?("//span", text: 'Nope')).to be false
|
|
44
44
|
end
|
|
45
|
+
|
|
46
|
+
it 'should accept selector filters' do
|
|
47
|
+
@session.visit('/form')
|
|
48
|
+
cbox = @session.find(:css, '#form_pets_dog')
|
|
49
|
+
expect(cbox.matches_selector?(:checkbox, id: 'form_pets_dog', option: 'dog', name: 'form[pets][]', checked: true)).to be true
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'should accept a custom filter block' do
|
|
53
|
+
@session.visit('/form')
|
|
54
|
+
cbox = @session.find(:css, '#form_pets_dog')
|
|
55
|
+
expect(cbox.matches_selector?(:checkbox){ |node| node[:id] == "form_pets_dog"}).to be true
|
|
56
|
+
expect(cbox.matches_selector?(:checkbox){ |node| node[:id] != "form_pets_dog"}).to be false
|
|
57
|
+
end
|
|
45
58
|
end
|
|
46
59
|
|
|
47
60
|
Capybara::SpecHelper.spec '#not_matches_selector?' do
|
|
@@ -70,22 +83,22 @@ Capybara::SpecHelper.spec '#not_matches_selector?' do
|
|
|
70
83
|
|
|
71
84
|
context "with text" do
|
|
72
85
|
it "should discard all matches where the given string is contained" do
|
|
73
|
-
expect(@element).not_to not_match_selector(:css, "span.number", :
|
|
74
|
-
expect(@element).to not_match_selector(:css, "span.number", :
|
|
86
|
+
expect(@element).not_to not_match_selector(:css, "span.number", text: "42")
|
|
87
|
+
expect(@element).to not_match_selector(:css, "span.number", text: "Doesnotexist")
|
|
75
88
|
end
|
|
76
89
|
end
|
|
77
90
|
|
|
78
91
|
it "should have CSS sugar" do
|
|
79
92
|
expect(@element.not_matches_css?("span.number")).to be false
|
|
80
93
|
expect(@element.not_matches_css?("p a#doesnotexist")).to be true
|
|
81
|
-
expect(@element.not_matches_css?("span.number", :
|
|
82
|
-
expect(@element.not_matches_css?("span.number", :
|
|
94
|
+
expect(@element.not_matches_css?("span.number", text: "42")).to be false
|
|
95
|
+
expect(@element.not_matches_css?("span.number", text: "Doesnotexist")).to be true
|
|
83
96
|
end
|
|
84
97
|
|
|
85
98
|
it "should have xpath sugar" do
|
|
86
99
|
expect(@element.not_matches_xpath?("//span")).to be false
|
|
87
100
|
expect(@element.not_matches_xpath?("//div")).to be true
|
|
88
|
-
expect(@element.not_matches_xpath?("//span", :
|
|
89
|
-
expect(@element.not_matches_xpath?("//span", :
|
|
101
|
+
expect(@element.not_matches_xpath?("//span", text: "42")).to be false
|
|
102
|
+
expect(@element.not_matches_xpath?("//span", text: "Doesnotexist")).to be true
|
|
90
103
|
end
|
|
91
104
|
end if Gem::Version.new(RSpec::Expectations::Version::STRING) >= Gem::Version.new('3.1')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
Capybara::SpecHelper.spec "#evaluate_script", :
|
|
2
|
+
Capybara::SpecHelper.spec "#evaluate_script", requires: [:js] do
|
|
3
3
|
it "should evaluate the given script and return whatever it produces" do
|
|
4
4
|
@session.visit('/with_js')
|
|
5
5
|
expect(@session.evaluate_script("1+3")).to eq(4)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
Capybara::SpecHelper.spec "#execute_script", :
|
|
2
|
+
Capybara::SpecHelper.spec "#execute_script", requires: [:js] do
|
|
3
3
|
it "should execute the given script and return nothing" do
|
|
4
4
|
@session.visit('/with_js')
|
|
5
5
|
expect(@session.execute_script("document.getElementById('change').textContent = 'Funky Doodle'")).to be_nil
|
|
6
|
-
expect(@session).to have_css('#change', :
|
|
6
|
+
expect(@session).to have_css('#change', text: 'Funky Doodle')
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it "should be able to call functions defined in the page" do
|
|
@@ -5,97 +5,97 @@ Capybara::SpecHelper.spec "#fill_in" do
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
it "should fill in a text field by id" do
|
|
8
|
-
@session.fill_in('form_first_name', :
|
|
8
|
+
@session.fill_in('form_first_name', with: 'Harry')
|
|
9
9
|
@session.click_button('awesome')
|
|
10
10
|
expect(extract_results(@session)['first_name']).to eq('Harry')
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it "should fill in a text field by name" do
|
|
14
|
-
@session.fill_in('form[last_name]', :
|
|
14
|
+
@session.fill_in('form[last_name]', with: 'Green')
|
|
15
15
|
@session.click_button('awesome')
|
|
16
16
|
expect(extract_results(@session)['last_name']).to eq('Green')
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should fill in a text field by label without for" do
|
|
20
|
-
@session.fill_in('First Name', :
|
|
20
|
+
@session.fill_in('First Name', with: 'Harry')
|
|
21
21
|
@session.click_button('awesome')
|
|
22
22
|
expect(extract_results(@session)['first_name']).to eq('Harry')
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "should fill in a url field by label without for" do
|
|
26
|
-
@session.fill_in('Html5 Url', :
|
|
26
|
+
@session.fill_in('Html5 Url', with: 'http://www.avenueq.com')
|
|
27
27
|
@session.click_button('html5_submit')
|
|
28
28
|
expect(extract_results(@session)['html5_url']).to eq('http://www.avenueq.com')
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "should fill in a textarea by id" do
|
|
32
|
-
@session.fill_in('form_description', :
|
|
32
|
+
@session.fill_in('form_description', with: 'Texty text')
|
|
33
33
|
@session.click_button('awesome')
|
|
34
34
|
expect(extract_results(@session)['description']).to eq('Texty text')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "should fill in a textarea by label" do
|
|
38
|
-
@session.fill_in('Description', :
|
|
38
|
+
@session.fill_in('Description', with: 'Texty text')
|
|
39
39
|
@session.click_button('awesome')
|
|
40
40
|
expect(extract_results(@session)['description']).to eq('Texty text')
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "should fill in a textarea by name" do
|
|
44
|
-
@session.fill_in('form[description]', :
|
|
44
|
+
@session.fill_in('form[description]', with: 'Texty text')
|
|
45
45
|
@session.click_button('awesome')
|
|
46
46
|
expect(extract_results(@session)['description']).to eq('Texty text')
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
it "should fill in a password field by id" do
|
|
50
|
-
@session.fill_in('form_password', :
|
|
50
|
+
@session.fill_in('form_password', with: 'supasikrit')
|
|
51
51
|
@session.click_button('awesome')
|
|
52
52
|
expect(extract_results(@session)['password']).to eq('supasikrit')
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "should handle HTML in a textarea" do
|
|
56
|
-
@session.fill_in('form_description', :
|
|
56
|
+
@session.fill_in('form_description', with: 'is <strong>very</strong> secret!')
|
|
57
57
|
@session.click_button('awesome')
|
|
58
58
|
expect(extract_results(@session)['description']).to eq('is <strong>very</strong> secret!')
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "should handle newlines in a textarea" do
|
|
62
|
-
@session.fill_in('form_description', :
|
|
62
|
+
@session.fill_in('form_description', with: "\nSome text\n")
|
|
63
63
|
@session.click_button('awesome')
|
|
64
64
|
expect(extract_results(@session)['description']).to eq("\r\nSome text\r\n")
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "should fill in a field with a custom type" do
|
|
68
|
-
@session.fill_in('Schmooo', :
|
|
68
|
+
@session.fill_in('Schmooo', with: 'Schmooo is the game')
|
|
69
69
|
@session.click_button('awesome')
|
|
70
70
|
expect(extract_results(@session)['schmooo']).to eq('Schmooo is the game')
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
it "should fill in a field without a type" do
|
|
74
|
-
@session.fill_in('Phone', :
|
|
74
|
+
@session.fill_in('Phone', with: '+1 555 7022')
|
|
75
75
|
@session.click_button('awesome')
|
|
76
76
|
expect(extract_results(@session)['phone']).to eq('+1 555 7022')
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
it "should fill in a text field respecting its maxlength attribute" do
|
|
80
|
-
@session.fill_in('Zipcode', :
|
|
80
|
+
@session.fill_in('Zipcode', with: '52071350')
|
|
81
81
|
@session.click_button('awesome')
|
|
82
82
|
expect(extract_results(@session)['zipcode']).to eq('52071')
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it "should fill in a password field by name" do
|
|
86
|
-
@session.fill_in('form[password]', :
|
|
86
|
+
@session.fill_in('form[password]', with: 'supasikrit')
|
|
87
87
|
@session.click_button('awesome')
|
|
88
88
|
expect(extract_results(@session)['password']).to eq('supasikrit')
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
it "should fill in a password field by label" do
|
|
92
|
-
@session.fill_in('Password', :
|
|
92
|
+
@session.fill_in('Password', with: 'supasikrit')
|
|
93
93
|
@session.click_button('awesome')
|
|
94
94
|
expect(extract_results(@session)['password']).to eq('supasikrit')
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
it "should fill in a password field by name" do
|
|
98
|
-
@session.fill_in('form[password]', :
|
|
98
|
+
@session.fill_in('form[password]', with: 'supasikrit')
|
|
99
99
|
@session.click_button('awesome')
|
|
100
100
|
expect(extract_results(@session)['password']).to eq('supasikrit')
|
|
101
101
|
end
|
|
@@ -104,39 +104,39 @@ Capybara::SpecHelper.spec "#fill_in" do
|
|
|
104
104
|
expect {@session.fill_in 'Name', 'ignu'}.to raise_error(RuntimeError, /with/)
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
-
it "should wait for asynchronous load", :
|
|
107
|
+
it "should wait for asynchronous load", requires: [:js] do
|
|
108
108
|
@session.visit('/with_js')
|
|
109
109
|
@session.click_link('Click me')
|
|
110
|
-
@session.fill_in('new_field', :
|
|
110
|
+
@session.fill_in('new_field', with: 'Testing...')
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it "casts to string" do
|
|
114
|
-
@session.fill_in(:'form_first_name', :
|
|
114
|
+
@session.fill_in(:'form_first_name', with: :'Harry')
|
|
115
115
|
@session.click_button('awesome')
|
|
116
116
|
expect(extract_results(@session)['first_name']).to eq('Harry')
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
it "casts to string if field has maxlength" do
|
|
120
|
-
@session.fill_in(:'form_zipcode', :
|
|
120
|
+
@session.fill_in(:'form_zipcode', with: 1234567)
|
|
121
121
|
@session.click_button('awesome')
|
|
122
122
|
expect(extract_results(@session)['zipcode']).to eq('12345')
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
-
context 'on a pre-populated textfield with a reformatting onchange', :
|
|
125
|
+
context 'on a pre-populated textfield with a reformatting onchange', requires: [:js] do
|
|
126
126
|
it 'should only trigger onchange once' do
|
|
127
127
|
@session.visit('/with_js')
|
|
128
|
-
@session.fill_in('with_change_event', :
|
|
128
|
+
@session.fill_in('with_change_event', with: 'some value')
|
|
129
129
|
# click outside the field to trigger the change event
|
|
130
130
|
@session.find(:css, 'body').click
|
|
131
|
-
expect(@session.find(:css, '.change_event_triggered', :
|
|
131
|
+
expect(@session.find(:css, '.change_event_triggered', match: :one)).to have_text 'some value'
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
it 'should trigger change when clearing field' do
|
|
135
135
|
@session.visit('/with_js')
|
|
136
|
-
@session.fill_in('with_change_event', :
|
|
136
|
+
@session.fill_in('with_change_event', with: '')
|
|
137
137
|
# click outside the field to trigger the change event
|
|
138
138
|
@session.find(:css, 'body').click
|
|
139
|
-
expect(@session).to have_selector(:css, '.change_event_triggered', :
|
|
139
|
+
expect(@session).to have_selector(:css, '.change_event_triggered', match: :one)
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
142
|
|
|
@@ -146,7 +146,7 @@ Capybara::SpecHelper.spec "#fill_in" do
|
|
|
146
146
|
it "should not find a hidden field" do
|
|
147
147
|
msg = "Unable to find field \"Super Secret\""
|
|
148
148
|
expect do
|
|
149
|
-
@session.fill_in('Super Secret', :
|
|
149
|
+
@session.fill_in('Super Secret', with: '777')
|
|
150
150
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
|
151
151
|
end
|
|
152
152
|
end
|
|
@@ -155,7 +155,7 @@ Capybara::SpecHelper.spec "#fill_in" do
|
|
|
155
155
|
it "should raise an error" do
|
|
156
156
|
msg = "Unable to find field \"does not exist\""
|
|
157
157
|
expect do
|
|
158
|
-
@session.fill_in('does not exist', :
|
|
158
|
+
@session.fill_in('does not exist', with: 'Blah blah')
|
|
159
159
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
|
160
160
|
end
|
|
161
161
|
end
|
|
@@ -163,21 +163,21 @@ Capybara::SpecHelper.spec "#fill_in" do
|
|
|
163
163
|
context "on a disabled field" do
|
|
164
164
|
it "should raise an error" do
|
|
165
165
|
expect do
|
|
166
|
-
@session.fill_in('Disabled Text Field', :
|
|
166
|
+
@session.fill_in('Disabled Text Field', with: 'Blah blah')
|
|
167
167
|
end.to raise_error(Capybara::ElementNotFound)
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
context "with :exact option" do
|
|
172
172
|
it "should accept partial matches when false" do
|
|
173
|
-
@session.fill_in("Explanation", :
|
|
173
|
+
@session.fill_in("Explanation", with: "Dude", exact: false)
|
|
174
174
|
@session.click_button("awesome")
|
|
175
175
|
expect(extract_results(@session)["name_explanation"]).to eq("Dude")
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
it "should not accept partial matches when true" do
|
|
179
179
|
expect do
|
|
180
|
-
@session.fill_in("Explanation", :
|
|
180
|
+
@session.fill_in("Explanation", with: "Dude", exact: true)
|
|
181
181
|
end.to raise_error(Capybara::ElementNotFound)
|
|
182
182
|
end
|
|
183
183
|
end
|
|
@@ -33,24 +33,24 @@ Capybara::SpecHelper.spec '#find_button' do
|
|
|
33
33
|
|
|
34
34
|
context "with :exact option" do
|
|
35
35
|
it "should accept partial matches when false" do
|
|
36
|
-
expect(@session.find_button('What an Awesome', :
|
|
36
|
+
expect(@session.find_button('What an Awesome', exact: false).value).to eq("awesome")
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "should not accept partial matches when true" do
|
|
40
40
|
expect do
|
|
41
|
-
@session.find_button('What an Awesome', :
|
|
41
|
+
@session.find_button('What an Awesome', exact: true)
|
|
42
42
|
end.to raise_error(Capybara::ElementNotFound)
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
context "with :disabled option" do
|
|
47
47
|
it "should find disabled buttons when true" do
|
|
48
|
-
expect(@session.find_button('Disabled button', :
|
|
48
|
+
expect(@session.find_button('Disabled button', disabled: true).value).to eq("Disabled button")
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should not find disabled buttons when false" do
|
|
52
52
|
expect do
|
|
53
|
-
@session.find_button('Disabled button', :
|
|
53
|
+
@session.find_button('Disabled button', disabled: false)
|
|
54
54
|
end.to raise_error(Capybara::ElementNotFound)
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -61,7 +61,7 @@ Capybara::SpecHelper.spec '#find_button' do
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "should find disabled buttons when :all" do
|
|
64
|
-
expect(@session.find_button('Disabled button', :
|
|
64
|
+
expect(@session.find_button('Disabled button', disabled: :all).value).to eq("Disabled button")
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -20,12 +20,12 @@ Capybara::SpecHelper.spec '#find_by_id' do
|
|
|
20
20
|
|
|
21
21
|
context "with :visible option" do
|
|
22
22
|
it "finds invisible elements when `false`" do
|
|
23
|
-
expect(@session.find_by_id("hidden_via_ancestor", :
|
|
23
|
+
expect(@session.find_by_id("hidden_via_ancestor", visible: false).text(:all)).to match(/with hidden ancestor/)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "finds invisible elements when `false`" do
|
|
27
27
|
expect do
|
|
28
|
-
@session.find_by_id("hidden_via_ancestor", :
|
|
28
|
+
@session.find_by_id("hidden_via_ancestor", visible: true)
|
|
29
29
|
end.to raise_error(Capybara::ElementNotFound)
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -8,7 +8,6 @@ Capybara::SpecHelper.spec '#find_field' do
|
|
|
8
8
|
expect(@session.find_field('Dog').value).to eq('dog')
|
|
9
9
|
expect(@session.find_field('form_description').text).to eq('Descriptive text goes here')
|
|
10
10
|
expect(@session.find_field('Region')[:name]).to eq('form[region]')
|
|
11
|
-
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
context "aria_label attribute with Capybara.enable_aria_label" do
|
|
@@ -50,24 +49,24 @@ Capybara::SpecHelper.spec '#find_field' do
|
|
|
50
49
|
|
|
51
50
|
context "with :exact option" do
|
|
52
51
|
it "should accept partial matches when false" do
|
|
53
|
-
expect(@session.find_field("Explanation", :
|
|
52
|
+
expect(@session.find_field("Explanation", exact: false)[:name]).to eq("form[name_explanation]")
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
it "should not accept partial matches when true" do
|
|
57
56
|
expect do
|
|
58
|
-
@session.find_field("Explanation", :
|
|
57
|
+
@session.find_field("Explanation", exact: true)
|
|
59
58
|
end.to raise_error(Capybara::ElementNotFound)
|
|
60
59
|
end
|
|
61
60
|
end
|
|
62
61
|
|
|
63
62
|
context "with :disabled option" do
|
|
64
63
|
it "should find disabled fields when true" do
|
|
65
|
-
expect(@session.find_field("Disabled Checkbox", :
|
|
64
|
+
expect(@session.find_field("Disabled Checkbox", disabled: true)[:name]).to eq("form[disabled_checkbox]")
|
|
66
65
|
end
|
|
67
66
|
|
|
68
67
|
it "should not find disabled fields when false" do
|
|
69
68
|
expect do
|
|
70
|
-
@session.find_field("Disabled Checkbox", :
|
|
69
|
+
@session.find_field("Disabled Checkbox", disabled: false)
|
|
71
70
|
end.to raise_error(Capybara::ElementNotFound)
|
|
72
71
|
end
|
|
73
72
|
|
|
@@ -78,11 +77,11 @@ Capybara::SpecHelper.spec '#find_field' do
|
|
|
78
77
|
end
|
|
79
78
|
|
|
80
79
|
it "should find disabled fields when :all" do
|
|
81
|
-
expect(@session.find_field("Disabled Checkbox", :
|
|
80
|
+
expect(@session.find_field("Disabled Checkbox", disabled: :all)[:name]).to eq("form[disabled_checkbox]")
|
|
82
81
|
end
|
|
83
82
|
|
|
84
83
|
it "should find enabled fields when :all" do
|
|
85
|
-
expect(@session.find_field('Dog', :
|
|
84
|
+
expect(@session.find_field('Dog', disabled: :all).value).to eq('dog')
|
|
86
85
|
end
|
|
87
86
|
end
|
|
88
87
|
|
|
@@ -107,4 +106,9 @@ Capybara::SpecHelper.spec '#find_field' do
|
|
|
107
106
|
expect(@session.find_field(with: 'dog')['id']).to eq "form_pets_dog"
|
|
108
107
|
end
|
|
109
108
|
end
|
|
109
|
+
|
|
110
|
+
it "should accept an optional filter block" do
|
|
111
|
+
# this would be better done with the :with option but this is just a test
|
|
112
|
+
expect(@session.find_field('form[pets][]'){ |node| node.value == 'dog' }[:id]).to eq "form_pets_dog"
|
|
113
|
+
end
|
|
110
114
|
end
|
|
@@ -33,12 +33,12 @@ Capybara::SpecHelper.spec '#find_link' do
|
|
|
33
33
|
|
|
34
34
|
context "with :exact option" do
|
|
35
35
|
it "should accept partial matches when false" do
|
|
36
|
-
expect(@session.find_link('abo', :
|
|
36
|
+
expect(@session.find_link('abo', exact: false).text).to eq("labore")
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "should not accept partial matches when true" do
|
|
40
40
|
expect do
|
|
41
|
-
@session.find_link('abo', :
|
|
41
|
+
@session.find_link('abo', exact: true)
|
|
42
42
|
end.to raise_error(Capybara::ElementNotFound)
|
|
43
43
|
end
|
|
44
44
|
end
|