capybara 3.31.0 → 3.32.1
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 +22 -0
- data/README.md +1 -1
- data/lib/capybara/minitest.rb +213 -138
- data/lib/capybara/minitest/spec.rb +153 -97
- data/lib/capybara/node/element.rb +2 -0
- data/lib/capybara/rack_test/browser.rb +3 -1
- data/lib/capybara/result.rb +1 -0
- data/lib/capybara/rspec/matcher_proxies.rb +4 -4
- data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
- data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
- data/lib/capybara/selenium/driver.rb +5 -4
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -2
- data/lib/capybara/selenium/node.rb +68 -9
- data/lib/capybara/selenium/nodes/chrome_node.rb +0 -9
- data/lib/capybara/selenium/nodes/firefox_node.rb +1 -1
- data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
- data/lib/capybara/spec/public/test.js +11 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +9 -0
- data/lib/capybara/spec/session/find_spec.rb +11 -8
- data/lib/capybara/spec/session/has_css_spec.rb +9 -6
- data/lib/capybara/spec/session/node_spec.rb +48 -21
- data/lib/capybara/spec/session/window/window_spec.rb +7 -7
- data/lib/capybara/spec/spec_helper.rb +1 -2
- data/lib/capybara/spec/views/form.erb +5 -0
- data/lib/capybara/spec/views/with_html.erb +2 -2
- data/lib/capybara/version.rb +1 -1
- data/spec/rack_test_spec.rb +12 -0
- data/spec/regexp_dissassembler_spec.rb +0 -4
- data/spec/result_spec.rb +37 -14
- data/spec/selenium_spec_chrome.rb +4 -0
- data/spec/selenium_spec_chrome_remote.rb +2 -0
- data/spec/shared_selenium_node.rb +18 -0
- data/spec/shared_selenium_session.rb +15 -6
- metadata +3 -2
@@ -141,12 +141,12 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
describe '#maximize' do
|
144
|
-
|
145
|
-
@
|
144
|
+
let! :initial_size do
|
145
|
+
@session.current_window.size
|
146
146
|
end
|
147
147
|
|
148
148
|
after do
|
149
|
-
@session.current_window.resize_to(
|
149
|
+
@session.current_window.resize_to(*initial_size)
|
150
150
|
sleep 0.5
|
151
151
|
end
|
152
152
|
|
@@ -176,7 +176,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
176
176
|
|
177
177
|
expect(@session.current_window).to eq(orig_window)
|
178
178
|
# Maximizing the browser affects all tabs so this may not be valid in real browsers
|
179
|
-
# expect(@session.current_window.size).to eq(
|
179
|
+
# expect(@session.current_window.size).to eq(initial_size)
|
180
180
|
|
181
181
|
ow_width, ow_height = other_window.size
|
182
182
|
expect(ow_width).to be > 400
|
@@ -185,12 +185,12 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
|
|
185
185
|
end
|
186
186
|
|
187
187
|
describe '#fullscreen' do
|
188
|
-
|
189
|
-
@
|
188
|
+
let! :initial_size do
|
189
|
+
@session.current_window.size
|
190
190
|
end
|
191
191
|
|
192
192
|
after do
|
193
|
-
@session.current_window.resize_to(
|
193
|
+
@session.current_window.resize_to(*initial_size)
|
194
194
|
sleep 1
|
195
195
|
end
|
196
196
|
|
@@ -60,7 +60,7 @@ module Capybara
|
|
60
60
|
RSpec.describe Capybara::Session, name, options do # rubocop:disable RSpec/EmptyExampleGroup
|
61
61
|
include Capybara::SpecHelper
|
62
62
|
include Capybara::RSpecMatchers
|
63
|
-
|
63
|
+
|
64
64
|
before do |example|
|
65
65
|
@session = session
|
66
66
|
instance_exec(example, &filter_block) if filter_block
|
@@ -81,7 +81,6 @@ module Capybara
|
|
81
81
|
before :each, :exact_false do
|
82
82
|
Capybara.exact = false
|
83
83
|
end
|
84
|
-
# rubocop:enable RSpec/ScatteredSetup
|
85
84
|
|
86
85
|
specs.each do |spec_name, spec_options, block|
|
87
86
|
describe spec_name, *spec_options do # rubocop:disable RSpec/EmptyExampleGroup
|
@@ -143,6 +143,10 @@
|
|
143
143
|
<input type="text" maxlength="5" name="form[zipcode]" id="form_zipcode" />
|
144
144
|
</p>
|
145
145
|
|
146
|
+
<p>
|
147
|
+
<input maxlength="35" id="long_length" />
|
148
|
+
</p>
|
149
|
+
|
146
150
|
<p>
|
147
151
|
<label for="form_tendency">Tendency</label>
|
148
152
|
<select name="form[tendency]" id="form_tendency"></select>
|
@@ -517,6 +521,7 @@ New line after and before textarea tag
|
|
517
521
|
|
518
522
|
<p>
|
519
523
|
<input type="submit" name="form[mediocre]" id="mediocre" value="med" aria-label="Mediocre Button"/>
|
524
|
+
<input type="submit" formaction="/form/get?bar=foo" id="mediocre2" value="med2"/>
|
520
525
|
<p>
|
521
526
|
</form>
|
522
527
|
|
@@ -36,8 +36,8 @@
|
|
36
36
|
</p>
|
37
37
|
|
38
38
|
<p>
|
39
|
-
<input type="text" id="test_field" data-test-id="test_id" value="monkey"/>
|
40
|
-
<input type="text" readonly="readonly" value="should not change" />
|
39
|
+
<input type="text" id="test_field" spellcheck="TRUE" data-test-id="test_id" value="monkey"/>
|
40
|
+
<input type="text" readonly="readonly" spellcheck="FALSE" value="should not change" />
|
41
41
|
<textarea id="normal" data-other-test-id="test_id">
|
42
42
|
banana</textarea>
|
43
43
|
<textarea id="additional_newline">
|
data/lib/capybara/version.rb
CHANGED
data/spec/rack_test_spec.rb
CHANGED
@@ -127,6 +127,18 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
|
|
127
127
|
session.find(:label, 'Female').click
|
128
128
|
expect(session).to have_unchecked_field('gender_male')
|
129
129
|
end
|
130
|
+
|
131
|
+
it 'should rewrite the forms action query for get submission' do
|
132
|
+
session.visit('/form')
|
133
|
+
session.click_button('mediocre')
|
134
|
+
expect(session).not_to have_current_path(/foo|bar/)
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should rewrite the submit buttons formaction query for get submission' do
|
138
|
+
session.visit('/form')
|
139
|
+
session.click_button('mediocre2')
|
140
|
+
expect(session).not_to have_current_path(/foo|bar/)
|
141
|
+
end
|
130
142
|
end
|
131
143
|
end
|
132
144
|
|
@@ -49,7 +49,6 @@ RSpec.describe Capybara::Selector::RegexpDisassembler, :aggregate_failures do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'handles optional characters for #alternated_substrings' do
|
52
|
-
# rubocop:disable Style/BracesAroundHashParameters
|
53
52
|
verify_alternated_strings(
|
54
53
|
{
|
55
54
|
/abc*def/ => [%w[ab def]],
|
@@ -62,7 +61,6 @@ RSpec.describe Capybara::Selector::RegexpDisassembler, :aggregate_failures do
|
|
62
61
|
/d?/ => []
|
63
62
|
}
|
64
63
|
)
|
65
|
-
# rubocop:enable Style/BracesAroundHashParameters
|
66
64
|
end
|
67
65
|
|
68
66
|
it 'handles character classes' do
|
@@ -140,7 +138,6 @@ RSpec.describe Capybara::Selector::RegexpDisassembler, :aggregate_failures do
|
|
140
138
|
end
|
141
139
|
|
142
140
|
it 'handles alternation for #alternated_substrings' do
|
143
|
-
# rubocop:disable Style/BracesAroundHashParameters
|
144
141
|
verify_alternated_strings(
|
145
142
|
{
|
146
143
|
/abc|def/ => [%w[abc], %w[def]],
|
@@ -173,7 +170,6 @@ RSpec.describe Capybara::Selector::RegexpDisassembler, :aggregate_failures do
|
|
173
170
|
/ab\\?cd/ => [%w[abcd], %w[ab\cd]]
|
174
171
|
}
|
175
172
|
)
|
176
|
-
# rubocop:enable Style/BracesAroundHashParameters
|
177
173
|
end
|
178
174
|
|
179
175
|
it 'handles grouping' do
|
data/spec/result_spec.rb
CHANGED
@@ -65,24 +65,47 @@ RSpec.describe Capybara::Result do
|
|
65
65
|
end).to eq(2)
|
66
66
|
end
|
67
67
|
|
68
|
+
def recalc_result
|
69
|
+
string.all '//li', minimum: 0 # pass minimum: 0 so lazy evaluation doesn't get triggered yet
|
70
|
+
end
|
71
|
+
|
68
72
|
it 'supports all modes of []' do
|
69
|
-
expect(
|
70
|
-
expect(
|
71
|
-
expect(
|
72
|
-
expect(
|
73
|
-
expect(
|
74
|
-
expect(
|
75
|
-
expect(
|
76
|
-
expect(
|
77
|
-
expect(
|
78
|
-
|
73
|
+
expect(recalc_result[1].text).to eq 'Beta'
|
74
|
+
expect(recalc_result[0, 2].map(&:text)).to eq %w[Alpha Beta]
|
75
|
+
expect(recalc_result[1..3].map(&:text)).to eq %w[Beta Gamma Delta]
|
76
|
+
expect(recalc_result[-1].text).to eq 'Delta'
|
77
|
+
expect(recalc_result[-2, 3].map(&:text)).to eq %w[Gamma Delta]
|
78
|
+
expect(recalc_result[1...3].map(&:text)).to eq %w[Beta Gamma]
|
79
|
+
expect(recalc_result[1..7].map(&:text)).to eq %w[Beta Gamma Delta]
|
80
|
+
expect(recalc_result[2...-1].map(&:text)).to eq %w[Gamma]
|
81
|
+
expect(recalc_result[2..-1].map(&:text)).to eq %w[Gamma Delta]
|
82
|
+
end
|
83
|
+
|
84
|
+
eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.5
|
85
|
+
it 'supports endless ranges' do
|
79
86
|
expect(result[2..].map(&:text)).to eq %w[Gamma Delta]
|
80
|
-
|
81
|
-
|
87
|
+
end
|
88
|
+
TEST
|
89
|
+
|
90
|
+
eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.6
|
91
|
+
it 'supports inclusive positive beginless ranges' do
|
82
92
|
expect(result[..2].map(&:text)).to eq %w[Alpha Beta Gamma]
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'supports inclusive negative beginless ranges' do
|
96
|
+
expect(result[..-2].map(&:text)).to eq %w[Alpha Beta Gamma]
|
97
|
+
expect(result[..-1].map(&:text)).to eq %w[Alpha Beta Gamma Delta]
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'supports exclusive positive beginless ranges' do
|
83
101
|
expect(result[...2].map(&:text)).to eq %w[Alpha Beta]
|
84
|
-
|
85
|
-
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'supports exclusive negative beginless ranges' do
|
105
|
+
expect(result[...-2].map(&:text)).to eq %w[Alpha Beta]
|
106
|
+
expect(result[...-1].map(&:text)).to eq %w[Alpha Beta Gamma]
|
107
|
+
end
|
108
|
+
TEST
|
86
109
|
|
87
110
|
it 'works with filter blocks' do
|
88
111
|
result = string.all('//li') { |node| node.text == 'Alpha' }
|
@@ -68,8 +68,12 @@ Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_DRIVER.to_s, capybar
|
|
68
68
|
skip 'Need to figure out testing of file downloading on windows platform' if Gem.win_platform?
|
69
69
|
when /Capybara::Session selenium_chrome Capybara::Window#maximize/
|
70
70
|
pending "Chrome headless doesn't support maximize" if ENV['HEADLESS']
|
71
|
+
when /Capybara::Window#fullscreen should be able to fullscreen the window/
|
72
|
+
skip 'Chromedriver hangs on attempts to fullscreen in headless mode' if ENV['HEADLESS']
|
71
73
|
when /details non-summary descendants should be non-visible/
|
72
74
|
pending 'Chromedriver built-in is_displayed is currently broken' if ENV['W3C'] == 'false'
|
75
|
+
when /node #right_click delay should delay the mouse up/
|
76
|
+
skip "Legacy selenium doesn't support separate right button down/up" if ENV['W3C'] == 'false'
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
@@ -62,6 +62,8 @@ Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_REMOTE_DRIVER.to_s,
|
|
62
62
|
'Capybara::Session selenium_chrome_remote #attach_file with multipart form should fire change once for each set of files uploaded',
|
63
63
|
'Capybara::Session selenium_chrome_remote #attach_file with multipart form should fire change once when uploading multiple files from empty'
|
64
64
|
pending "Selenium with Remote Chrome doesn't support multiple file upload" unless selenium_gte?(3.14)
|
65
|
+
when /node #right_click delay should delay the mouse up/
|
66
|
+
skip "Legacy selenium doesn't support separate right button down/up" if ENV['W3C'] == 'false'
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
@@ -27,6 +27,24 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
describe '#[]' do
|
31
|
+
it 'should work for spellcheck' do
|
32
|
+
session.visit('/with_html')
|
33
|
+
expect(session.find('//input[@spellcheck="TRUE"]')[:spellcheck]).to eq('true')
|
34
|
+
expect(session.find('//input[@spellcheck="FALSE"]')[:spellcheck]).to eq('false')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#set' do
|
39
|
+
it 'respects maxlength when using rapid set' do
|
40
|
+
session.visit('/form')
|
41
|
+
inp = session.find(:css, '#long_length')
|
42
|
+
value = (0...50).map { |i| ((i % 26) + 65).chr }.join
|
43
|
+
inp.set(value, rapid: true)
|
44
|
+
expect(inp.value).to eq value[0...35]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
30
48
|
describe '#visible?' do
|
31
49
|
let(:bridge) do
|
32
50
|
session.driver.browser.send(:bridge)
|
@@ -441,21 +441,30 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
441
441
|
context 'controlled components' do
|
442
442
|
it 'can set and clear a text field' do
|
443
443
|
skip "This test doesn't support older browsers" if ie?(session)
|
444
|
-
|
445
|
-
# session.all(:css, 'h2#controlled-components ~ p a', text: 'Try it on CodePen')[0].click
|
446
|
-
# copied into local view
|
444
|
+
|
447
445
|
session.visit 'react'
|
448
|
-
|
449
|
-
# session.within_frame(:css, 'iframe.result-iframe:not([src=""])', wait: 10) do
|
446
|
+
|
450
447
|
session.fill_in('Name:', with: 'abc')
|
451
448
|
session.accept_prompt 'A name was submitted: abc' do
|
452
449
|
session.click_button('Submit')
|
453
450
|
end
|
451
|
+
|
454
452
|
session.fill_in('Name:', with: '')
|
455
453
|
session.accept_prompt(/A name was submitted: $/) do
|
456
454
|
session.click_button('Submit')
|
457
455
|
end
|
458
|
-
|
456
|
+
end
|
457
|
+
|
458
|
+
it 'works with rapid fill' do
|
459
|
+
skip "This test doesn't support older browsers" if ie?(session)
|
460
|
+
|
461
|
+
session.visit 'react'
|
462
|
+
long_string = (0...60).map { |i| ((i % 26) + 65).chr }.join
|
463
|
+
|
464
|
+
session.fill_in('Name:', with: long_string)
|
465
|
+
session.accept_prompt "A name was submitted: #{long_string}" do
|
466
|
+
session.click_button('Submit')
|
467
|
+
end
|
459
468
|
end
|
460
469
|
end
|
461
470
|
end
|
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.32.1
|
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: 2020-
|
13
|
+
date: 2020-04-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -528,6 +528,7 @@ files:
|
|
528
528
|
- lib/capybara/selenium/nodes/firefox_node.rb
|
529
529
|
- lib/capybara/selenium/nodes/ie_node.rb
|
530
530
|
- lib/capybara/selenium/nodes/safari_node.rb
|
531
|
+
- lib/capybara/selenium/patches/action_pauser.rb
|
531
532
|
- lib/capybara/selenium/patches/atoms.rb
|
532
533
|
- lib/capybara/selenium/patches/is_displayed.rb
|
533
534
|
- lib/capybara/selenium/patches/logs.rb
|