capybara 3.4.0 → 3.5.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 +25 -0
- data/README.md +1 -1
- data/lib/capybara/node/element.rb +3 -1
- data/lib/capybara/node/matchers.rb +21 -3
- data/lib/capybara/queries/text_query.rb +2 -1
- data/lib/capybara/rspec/matchers.rb +26 -38
- data/lib/capybara/selenium/driver.rb +2 -2
- data/lib/capybara/selenium/node.rb +8 -1
- data/lib/capybara/selenium/nodes/chrome_node.rb +1 -1
- data/lib/capybara/selenium/nodes/marionette_node.rb +5 -2
- data/lib/capybara/session.rb +1 -1
- data/lib/capybara/spec/public/jquery.js +5 -5
- data/lib/capybara/spec/public/test.js +3 -0
- data/lib/capybara/spec/session/assert_selector_spec.rb +6 -2
- data/lib/capybara/spec/session/assert_text_spec.rb +6 -1
- data/lib/capybara/spec/session/attach_file_spec.rb +15 -0
- data/lib/capybara/spec/session/check_spec.rb +7 -0
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +11 -0
- data/lib/capybara/spec/session/has_text_spec.rb +5 -0
- data/lib/capybara/spec/views/form.erb +6 -0
- data/lib/capybara/spec/views/with_js.erb +4 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/dsl_spec.rb +2 -1
- data/spec/minitest_spec.rb +9 -1
- data/spec/rspec/shared_spec_matchers.rb +2 -2
- data/spec/selenium_spec_chrome_remote.rb +8 -2
- data/spec/selenium_spec_firefox_remote.rb +3 -0
- data/spec/selenium_spec_ie.rb +9 -1
- data/spec/selenium_spec_marionette.rb +5 -0
- data/spec/shared_selenium_session.rb +7 -3
- metadata +2 -2
|
@@ -94,6 +94,21 @@ Capybara::SpecHelper.spec '#attach_file' do
|
|
|
94
94
|
expect(@session.body).to include(File.read(@another_test_file_path))
|
|
95
95
|
expect(@session.body).not_to include(File.read(@test_file_path))
|
|
96
96
|
end
|
|
97
|
+
|
|
98
|
+
it 'should fire change once when uploading multiple files from empty', requires: [:js] do
|
|
99
|
+
@session.visit('with_js')
|
|
100
|
+
@session.attach_file('multiple-file',
|
|
101
|
+
[@test_file_path, @another_test_file_path].map { |f| with_os_path_separators(f) })
|
|
102
|
+
expect(@session).to have_css('.file_change', count: 1)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should fire change once for each set of files uploaded', requires: [:js] do
|
|
106
|
+
@session.visit('with_js')
|
|
107
|
+
@session.attach_file('multiple-file', [@test_jpg_file_path].map { |f| with_os_path_separators(f) })
|
|
108
|
+
@session.attach_file('multiple-file',
|
|
109
|
+
[@test_file_path, @another_test_file_path].map { |f| with_os_path_separators(f) })
|
|
110
|
+
expect(@session).to have_css('.file_change', count: 2)
|
|
111
|
+
end
|
|
97
112
|
end
|
|
98
113
|
|
|
99
114
|
context "with a locator that doesn't exist" do
|
|
@@ -195,6 +195,13 @@ Capybara::SpecHelper.spec '#check' do
|
|
|
195
195
|
@session.click_button('awesome')
|
|
196
196
|
expect(extract_results(@session)['cars']).to include('pagani')
|
|
197
197
|
end
|
|
198
|
+
|
|
199
|
+
it 'should check via the label if input is visible but blocked by another element' do
|
|
200
|
+
expect(@session.find(:checkbox, 'form_cars_bugatti', unchecked: true, visible: :all)).to be_truthy
|
|
201
|
+
@session.check('form_cars_bugatti', allow_label_click: true)
|
|
202
|
+
@session.click_button('awesome')
|
|
203
|
+
expect(extract_results(@session)['cars']).to include('bugatti')
|
|
204
|
+
end
|
|
198
205
|
end
|
|
199
206
|
end
|
|
200
207
|
end
|
|
@@ -24,6 +24,17 @@ Capybara::SpecHelper.spec '#match_selector?' do
|
|
|
24
24
|
expect(@element).to match_selector('span.number')
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
it 'should work with elements located via a sibling selector' do
|
|
28
|
+
sibling = @element.sibling(:css, 'span', text: 'Other span')
|
|
29
|
+
expect(sibling).to match_selector(:xpath, '//span')
|
|
30
|
+
expect(sibling).to match_selector(:css, 'span')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should work with the html element' do
|
|
34
|
+
html = @session.find('/html')
|
|
35
|
+
expect(html).to match_selector(:css, 'html')
|
|
36
|
+
end
|
|
37
|
+
|
|
27
38
|
context 'with text' do
|
|
28
39
|
it 'should discard all matches where the given string is not contained' do
|
|
29
40
|
expect(@element).to match_selector('//span', text: '42')
|
|
@@ -34,6 +34,11 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|
|
34
34
|
expect(@session).to have_text('text with whitespace')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
it 'should search whitespace collapsed text' do
|
|
38
|
+
@session.visit('/with_html')
|
|
39
|
+
expect(@session).to have_text('text with whitespace', normalize_ws: true)
|
|
40
|
+
end
|
|
41
|
+
|
|
37
42
|
it 'should be false if the given text is not on the page' do
|
|
38
43
|
@session.visit('/with_html')
|
|
39
44
|
expect(@session).not_to have_text('xxxxyzzz')
|
|
@@ -185,6 +185,12 @@ New line after and before textarea tag
|
|
|
185
185
|
<label for="form_cars_ferrari">Ferrari</label>
|
|
186
186
|
<input type="checkbox" value="pagani" name="form[cars][]" id="form_cars_pagani" style="position: absolute; left: -9999px"/>
|
|
187
187
|
<label for="form_cars_pagani">Pagani</label>
|
|
188
|
+
<div style="position: relative;">
|
|
189
|
+
<input type="checkbox" value="bugatti" name="form[cars][]" id="form_cars_bugatti"/>
|
|
190
|
+
<div style="position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-color: #fff;">
|
|
191
|
+
<label for="form_cars_bugatti">Bugatti</label>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
188
194
|
<input type="checkbox" value="ariel" name="form[cars][]" id="form_cars_ariel" style="display: none"/>
|
|
189
195
|
<input type="checkbox" value="porsche" name="form[cars][]" id="form_cars_porsche" checked="checked" style="display: none"/>
|
|
190
196
|
<label>
|
|
@@ -125,6 +125,10 @@
|
|
|
125
125
|
<input type="file" id="hidden_file" style="opacity:0; display: none;">
|
|
126
126
|
</p>
|
|
127
127
|
|
|
128
|
+
<p>
|
|
129
|
+
<input type="file" id="multiple-file" multiple="multiple"/>
|
|
130
|
+
</p>
|
|
131
|
+
|
|
128
132
|
<div id="drag_scroll">
|
|
129
133
|
<p>This is a draggable element.</p>
|
|
130
134
|
</div>
|
data/lib/capybara/version.rb
CHANGED
data/spec/dsl_spec.rb
CHANGED
|
@@ -11,7 +11,8 @@ Capybara::SpecHelper.run_specs TestClass.new, 'DSL', capybara_skip: %i[
|
|
|
11
11
|
js modals screenshot frames windows send_keys server hover about_scheme psc download css
|
|
12
12
|
] do |example|
|
|
13
13
|
case example.metadata[:full_description]
|
|
14
|
-
when /doesn't raise exception on a nil current_url
|
|
14
|
+
when /doesn't raise exception on a nil current_url$/,
|
|
15
|
+
/#refute_selector should warn not to use$/
|
|
15
16
|
skip 'Only makes sense when there is a real driver'
|
|
16
17
|
end
|
|
17
18
|
end
|
data/spec/minitest_spec.rb
CHANGED
|
@@ -47,6 +47,14 @@ class MinitestTest < Minitest::Test
|
|
|
47
47
|
assert_no_css('select#not_form_title')
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
def test_assert_selector
|
|
51
|
+
assert_selector(:css, 'select#form_title')
|
|
52
|
+
assert_selector(:xpath, './/select[@id="form_title"]')
|
|
53
|
+
assert_no_selector(:css, 'select#not_form_title')
|
|
54
|
+
assert_no_selector(:xpath, './/select[@id="not_form_title"]')
|
|
55
|
+
refute_selector(:css, 'select#not_form_title')
|
|
56
|
+
end
|
|
57
|
+
|
|
50
58
|
def test_assert_link
|
|
51
59
|
visit('/with_html')
|
|
52
60
|
assert_link('A link')
|
|
@@ -132,6 +140,6 @@ RSpec.describe 'capybara/minitest' do
|
|
|
132
140
|
reporter.start
|
|
133
141
|
MinitestTest.run reporter, {}
|
|
134
142
|
reporter.report
|
|
135
|
-
expect(output.string).to include('
|
|
143
|
+
expect(output.string).to include('19 runs, 49 assertions, 0 failures, 0 errors, 1 skips')
|
|
136
144
|
end
|
|
137
145
|
end
|
|
@@ -496,11 +496,11 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|
|
496
496
|
expect(have_link('Just a link').description).to eq('have visible link "Just a link"')
|
|
497
497
|
end
|
|
498
498
|
|
|
499
|
-
it 'passes if there is such a
|
|
499
|
+
it 'passes if there is such a link' do
|
|
500
500
|
expect(html).to have_link('Just a link')
|
|
501
501
|
end
|
|
502
502
|
|
|
503
|
-
it 'fails if there is no such
|
|
503
|
+
it 'fails if there is no such link' do
|
|
504
504
|
expect do
|
|
505
505
|
expect(html).to have_link('No such Link')
|
|
506
506
|
end.to raise_error(/expected to find link "No such Link"/)
|
|
@@ -30,6 +30,10 @@ def ensure_selenium_running!
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
def selenium_gte?(version)
|
|
34
|
+
defined?(Selenium::WebDriver::VERSION) && (Selenium::WebDriver::VERSION.to_f >= version)
|
|
35
|
+
end
|
|
36
|
+
|
|
33
37
|
Capybara.register_driver :selenium_chrome_remote do |app|
|
|
34
38
|
ensure_selenium_running!
|
|
35
39
|
|
|
@@ -60,8 +64,10 @@ skipped_tests << :windows if ENV['TRAVIS'] && (ENV['SKIP_WINDOW'] || ENV['HEADLE
|
|
|
60
64
|
|
|
61
65
|
Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_REMOTE_DRIVER.to_s, capybara_skip: skipped_tests do |example|
|
|
62
66
|
case example.metadata[:full_description]
|
|
63
|
-
when 'Capybara::Session selenium_chrome_remote #attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files'
|
|
64
|
-
|
|
67
|
+
when 'Capybara::Session selenium_chrome_remote #attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files',
|
|
68
|
+
'Capybara::Session selenium_chrome_remote #attach_file with multipart form should fire change once for each set of files uploaded',
|
|
69
|
+
'Capybara::Session selenium_chrome_remote #attach_file with multipart form should fire change once when uploading multiple files from empty'
|
|
70
|
+
pending "Selenium with Remote Chrome doesn't support multiple file upload" unless selenium_gte?(3.14)
|
|
65
71
|
end
|
|
66
72
|
end
|
|
67
73
|
|
|
@@ -72,6 +72,9 @@ Capybara::SpecHelper.run_specs TestSessions::RemoteFirefox, FIREFOX_REMOTE_DRIVE
|
|
|
72
72
|
skip 'Firefox insists on prompting without providing a way to suppress'
|
|
73
73
|
when 'Capybara::Session selenium_firefox_remote #accept_prompt should accept the prompt with a blank response when there is a default'
|
|
74
74
|
pending "Geckodriver doesn't set a blank response currently"
|
|
75
|
+
when 'Capybara::Session selenium_firefox_remote #attach_file with multipart form should fire change once for each set of files uploaded',
|
|
76
|
+
'Capybara::Session selenium_firefox_remote #attach_file with multipart form should fire change once when uploading multiple files from empty'
|
|
77
|
+
pending 'Due to having to work around selenium remote lack of multiple file upload support the change event count is off'
|
|
75
78
|
end
|
|
76
79
|
end
|
|
77
80
|
|
data/spec/selenium_spec_ie.rb
CHANGED
|
@@ -22,10 +22,18 @@ skipped_tests = %i[response_headers status_code trigger modals hover form_attrib
|
|
|
22
22
|
|
|
23
23
|
$stdout.puts `#{Selenium::WebDriver::IE.driver_path} --version` if ENV['CI']
|
|
24
24
|
|
|
25
|
+
TestSessions::SeleniumIE.current_window.resize_to(1600, 1200)
|
|
26
|
+
|
|
25
27
|
Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_skip: skipped_tests do |example|
|
|
26
|
-
case example.metadata[:
|
|
28
|
+
case example.metadata[:full_description]
|
|
27
29
|
when /#refresh it reposts$/
|
|
28
30
|
skip 'Firefox and Edge insist on prompting without providing a way to suppress'
|
|
31
|
+
when /#click_link can download a file$/
|
|
32
|
+
skip 'Not sure how to configure IE for automatic downloading'
|
|
33
|
+
when /#fill_in with Date /
|
|
34
|
+
pending "IE 11 doesn't support date input types"
|
|
35
|
+
when /#click_link_or_button with :disabled option happily clicks on links which incorrectly have the disabled attribute$/
|
|
36
|
+
pending 'IE 11 obeys non-standard disabled attribute on anchor tag'
|
|
29
37
|
end
|
|
30
38
|
end
|
|
31
39
|
|
|
@@ -62,6 +62,11 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumMarionette, 'selenium', cap
|
|
|
62
62
|
skip 'Firefox insists on prompting without providing a way to suppress'
|
|
63
63
|
when 'Capybara::Session selenium #accept_prompt should accept the prompt with a blank response when there is a default'
|
|
64
64
|
pending "Geckodriver doesn't set a blank response currently"
|
|
65
|
+
when 'Capybara::Session selenium #attach_file with multipart form should fire change once for each set of files uploaded'
|
|
66
|
+
pending 'Gekcodriver appends files so we have to first call clear for multiple files which creates an extra change ' \
|
|
67
|
+
'if files are already set'
|
|
68
|
+
when 'Capybara::Session selenium #attach_file with multipart form should fire change once when uploading multiple files from empty'
|
|
69
|
+
pending "FF < 62 doesn't support setting all files at once" if marionette_lt?(62, @session)
|
|
65
70
|
end
|
|
66
71
|
end
|
|
67
72
|
|
|
@@ -39,14 +39,14 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it 'should have return code 1 when running selenium_driver_rspec_failure.rb' do
|
|
42
|
-
skip if headless_or_remote?
|
|
42
|
+
skip 'only setup for local non-headless' if headless_or_remote?
|
|
43
43
|
|
|
44
44
|
system(@env, 'rspec spec/fixtures/selenium_driver_rspec_failure.rb', out: File::NULL, err: File::NULL)
|
|
45
45
|
expect($CHILD_STATUS.exitstatus).to eq(1)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it 'should have return code 0 when running selenium_driver_rspec_success.rb' do
|
|
49
|
-
skip if headless_or_remote?
|
|
49
|
+
skip 'only setup for local non-headless' if headless_or_remote?
|
|
50
50
|
|
|
51
51
|
system(@env, 'rspec spec/fixtures/selenium_driver_rspec_success.rb', out: File::NULL, err: File::NULL)
|
|
52
52
|
expect($CHILD_STATUS.exitstatus).to eq(0)
|
|
@@ -169,11 +169,13 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
it 'should generate standard events on changing value' do
|
|
172
|
+
pending "IE 11 doesn't support date input type" if ie?(session)
|
|
172
173
|
session.fill_in('form_date', with: Date.today)
|
|
173
174
|
expect(session.evaluate_script('window.capybara_formDateFiredEvents')).to eq %w[focus input change]
|
|
174
175
|
end
|
|
175
176
|
|
|
176
177
|
it 'should not generate input and change events if the value is not changed' do
|
|
178
|
+
pending "IE 11 doesn't support date input type" if ie?(session)
|
|
177
179
|
session.fill_in('form_date', with: Date.today)
|
|
178
180
|
session.fill_in('form_date', with: Date.today)
|
|
179
181
|
# Chrome adds an extra focus for some reason - ok for now
|
|
@@ -202,13 +204,15 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
202
204
|
end
|
|
203
205
|
|
|
204
206
|
it 'handles namespaces' do
|
|
207
|
+
pending "IE 11 doesn't handle all XPath querys (namespace-uri, etc)" if ie?(session)
|
|
205
208
|
session.visit '/with_namespace'
|
|
206
|
-
rect = session.find(:css, 'div svg rect')
|
|
209
|
+
rect = session.find(:css, 'div svg rect:first-of-type')
|
|
207
210
|
expect(rect.path).to eq("/HTML/BODY/DIV/./*[((local-name(.) = 'svg') and (namespace-uri(.) = 'http://www.w3.org/2000/svg'))]/./*[((local-name(.) = 'rect') and (namespace-uri(.) = 'http://www.w3.org/2000/svg'))][1]")
|
|
208
211
|
expect(session.find(:xpath, rect.path)).to eq rect
|
|
209
212
|
end
|
|
210
213
|
|
|
211
214
|
it 'handles case sensitive element names' do
|
|
215
|
+
pending "IE 11 doesn't handle all XPath querys (namespace-uri, etc)" if ie?(session)
|
|
212
216
|
session.visit '/with_namespace'
|
|
213
217
|
els = session.all(:css, 'div *', visible: :all)
|
|
214
218
|
expect { els.map(&:path) }.not_to raise_error
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capybara
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Walpole
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain:
|
|
12
12
|
- gem-public_cert.pem
|
|
13
|
-
date: 2018-
|
|
13
|
+
date: 2018-08-01 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: addressable
|