capybara 3.16.1 → 3.17.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 +27 -0
- data/README.md +2 -2
- data/lib/capybara/config.rb +1 -2
- data/lib/capybara/node/actions.rb +5 -5
- data/lib/capybara/node/base.rb +4 -4
- data/lib/capybara/node/element.rb +5 -5
- data/lib/capybara/node/finders.rb +6 -4
- data/lib/capybara/node/simple.rb +3 -2
- data/lib/capybara/queries/selector_query.rb +5 -5
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/registrations/drivers.rb +36 -0
- data/lib/capybara/registrations/servers.rb +38 -0
- data/lib/capybara/result.rb +2 -2
- data/lib/capybara/rspec/matcher_proxies.rb +2 -2
- data/lib/capybara/rspec/matchers/base.rb +2 -2
- data/lib/capybara/selector/css.rb +1 -1
- data/lib/capybara/selector/filters/base.rb +1 -1
- data/lib/capybara/selector/selector.rb +1 -0
- data/lib/capybara/selector.rb +55 -32
- data/lib/capybara/selenium/driver.rb +84 -43
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +16 -4
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +23 -0
- data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +5 -0
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +14 -1
- data/lib/capybara/selenium/extensions/find.rb +48 -37
- data/lib/capybara/selenium/logger_suppressor.rb +29 -0
- data/lib/capybara/selenium/node.rb +22 -8
- data/lib/capybara/selenium/nodes/chrome_node.rb +8 -2
- data/lib/capybara/server/animation_disabler.rb +1 -1
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +3 -3
- data/lib/capybara/session/config.rb +2 -8
- data/lib/capybara/session.rb +1 -1
- data/lib/capybara/spec/session/attach_file_spec.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +4 -4
- data/lib/capybara/spec/session/choose_spec.rb +2 -2
- data/lib/capybara/spec/session/click_button_spec.rb +28 -1
- data/lib/capybara/spec/session/fill_in_spec.rb +2 -2
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +14 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +12 -1
- data/lib/capybara/spec/session/node_spec.rb +18 -6
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +1 -1
- data/lib/capybara/spec/views/frame_child.erb +2 -1
- data/lib/capybara/spec/views/react.erb +45 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +1 -1
- data/lib/capybara.rb +2 -71
- data/spec/minitest_spec_spec.rb +1 -1
- data/spec/result_spec.rb +10 -6
- data/spec/rspec/shared_spec_matchers.rb +8 -4
- data/spec/selector_spec.rb +4 -0
- data/spec/selenium_spec_safari.rb +2 -3
- data/spec/session_spec.rb +7 -0
- data/spec/shared_selenium_session.rb +14 -11
- data/spec/spec_helper.rb +2 -1
- metadata +6 -16
data/spec/result_spec.rb
CHANGED
|
@@ -106,7 +106,7 @@ RSpec.describe Capybara::Result do
|
|
|
106
106
|
|
|
107
107
|
# Not a great test but it indirectly tests what is needed
|
|
108
108
|
it 'should evaluate filters lazily for idx' do
|
|
109
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
|
109
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
|
110
110
|
# Not processed until accessed
|
|
111
111
|
expect(result.instance_variable_get('@result_cache').size).to be 0
|
|
112
112
|
|
|
@@ -127,7 +127,7 @@ RSpec.describe Capybara::Result do
|
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
it 'should evaluate filters lazily for range' do
|
|
130
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
|
130
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
|
131
131
|
result[0..1]
|
|
132
132
|
expect(result.instance_variable_get('@result_cache').size).to be 2
|
|
133
133
|
|
|
@@ -136,7 +136,7 @@ RSpec.describe Capybara::Result do
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it 'should evaluate filters lazily for idx and length' do
|
|
139
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
|
139
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
|
140
140
|
result[1, 2]
|
|
141
141
|
expect(result.instance_variable_get('@result_cache').size).to be 3
|
|
142
142
|
|
|
@@ -145,7 +145,7 @@ RSpec.describe Capybara::Result do
|
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
it 'should only need to evaluate one result for any?' do
|
|
148
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
|
148
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
|
149
149
|
result.any?
|
|
150
150
|
expect(result.instance_variable_get('@result_cache').size).to be 1
|
|
151
151
|
end
|
|
@@ -158,7 +158,7 @@ RSpec.describe Capybara::Result do
|
|
|
158
158
|
|
|
159
159
|
context '#each' do
|
|
160
160
|
it 'lazily evaluates' do
|
|
161
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
|
161
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
|
162
162
|
results = []
|
|
163
163
|
result.each do |el|
|
|
164
164
|
results << el
|
|
@@ -174,7 +174,7 @@ RSpec.describe Capybara::Result do
|
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
it 'lazily evaluates' do
|
|
177
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
|
177
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
|
178
178
|
result.each.with_index do |_el, idx|
|
|
179
179
|
expect(result.instance_variable_get('@result_cache').size).to eq(idx + 1) # 0 indexing
|
|
180
180
|
end
|
|
@@ -197,4 +197,8 @@ RSpec.describe Capybara::Result do
|
|
|
197
197
|
expect(eval_count).to eq 1
|
|
198
198
|
end
|
|
199
199
|
end
|
|
200
|
+
|
|
201
|
+
def jruby_lazy_enumerator_workaround?
|
|
202
|
+
(RUBY_PLATFORM == 'java') && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.2.8.0'))
|
|
203
|
+
end
|
|
200
204
|
end
|
|
@@ -627,8 +627,12 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|
|
627
627
|
describe 'have_button matcher' do
|
|
628
628
|
let(:html) { '<button>A button</button><input type="submit" value="Another button"/>' }
|
|
629
629
|
|
|
630
|
-
it 'gives proper description' do
|
|
631
|
-
expect(have_button('A button').description).to eq('have visible button "A button"')
|
|
630
|
+
it 'gives proper description with no options' do
|
|
631
|
+
expect(have_button('A button').description).to eq('have visible button "A button" that is not disabled')
|
|
632
|
+
end
|
|
633
|
+
|
|
634
|
+
it 'gives proper description with disabled :any option' do
|
|
635
|
+
expect(have_button('A button', disabled: :all).description).to eq('have visible button "A button"')
|
|
632
636
|
end
|
|
633
637
|
|
|
634
638
|
it 'passes if there is such a button' do
|
|
@@ -698,7 +702,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|
|
698
702
|
end
|
|
699
703
|
|
|
700
704
|
it 'gives proper description' do
|
|
701
|
-
expect(have_checked_field('it is checked').description).to eq('have visible field "it is checked" that is
|
|
705
|
+
expect(have_checked_field('it is checked').description).to eq('have visible field "it is checked" that is not disabled that is checked')
|
|
702
706
|
end
|
|
703
707
|
|
|
704
708
|
context 'with should' do
|
|
@@ -747,7 +751,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|
|
747
751
|
end
|
|
748
752
|
|
|
749
753
|
it 'gives proper description' do
|
|
750
|
-
expect(have_unchecked_field('unchecked field').description).to eq('have visible field "unchecked field" that is not
|
|
754
|
+
expect(have_unchecked_field('unchecked field').description).to eq('have visible field "unchecked field" that is not disabled that is not checked')
|
|
751
755
|
end
|
|
752
756
|
|
|
753
757
|
context 'with should' do
|
data/spec/selector_spec.rb
CHANGED
|
@@ -478,6 +478,10 @@ RSpec.describe Capybara do
|
|
|
478
478
|
Capybara::Selector[:link_or_button].expression_filters.delete(:random)
|
|
479
479
|
end
|
|
480
480
|
|
|
481
|
+
it 'should not find links when disabled == true' do
|
|
482
|
+
expect(string.all(:link_or_button, disabled: true).size).to eq 0
|
|
483
|
+
end
|
|
484
|
+
|
|
481
485
|
context 'when modified' do
|
|
482
486
|
it 'should still work' do
|
|
483
487
|
filter = Capybara::Selector[:link_or_button].expression_filters[:random]
|
|
@@ -57,10 +57,9 @@ Capybara::SpecHelper.run_specs TestSessions::Safari, SAFARI_DRIVER.to_s, capybar
|
|
|
57
57
|
'Capybara::Session selenium_safari node #click should allow to retry longer',
|
|
58
58
|
'Capybara::Session selenium_safari node #click should retry clicking'
|
|
59
59
|
pending "safaridriver doesn't return a specific enough error to deal with this"
|
|
60
|
-
when /Capybara::Session selenium_safari #within_frame
|
|
61
|
-
/Capybara::Session selenium_safari #within_frame works if the frame is closed/,
|
|
60
|
+
when /Capybara::Session selenium_safari #within_frame works if the frame is closed/,
|
|
62
61
|
/Capybara::Session selenium_safari #switch_to_frame works if the frame is closed/
|
|
63
|
-
skip '
|
|
62
|
+
skip 'Safari has a race condition when clicking an element that causes the frame to close. It will sometimes raise a NoSuchFrameError'
|
|
64
63
|
when /Capybara::Session selenium_safari #reset_session! removes ALL cookies/
|
|
65
64
|
skip 'Safari webdriver can only remove cookies for the current domain'
|
|
66
65
|
when /Capybara::Session selenium_safari #refresh it reposts/
|
data/spec/session_spec.rb
CHANGED
|
@@ -80,5 +80,12 @@ RSpec.describe Capybara::Session do
|
|
|
80
80
|
session.quit
|
|
81
81
|
expect(session.driver).not_to eql driver
|
|
82
82
|
end
|
|
83
|
+
|
|
84
|
+
it 'resets the document' do
|
|
85
|
+
session = Capybara::Session.new(:rack_test, TestApp)
|
|
86
|
+
document = session.document
|
|
87
|
+
session.quit
|
|
88
|
+
expect(session.document.base).not_to eql document.base
|
|
89
|
+
end
|
|
83
90
|
end
|
|
84
91
|
end
|
|
@@ -472,18 +472,21 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
472
472
|
describe 'with react' do
|
|
473
473
|
context 'controlled components' do
|
|
474
474
|
it 'can set and clear a text field' do
|
|
475
|
-
session.visit 'https://reactjs.org/docs/forms.html'
|
|
476
|
-
session.all(:css, 'h2#controlled-components ~ p a', text: 'Try it on CodePen')[0].click
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
session.
|
|
484
|
-
|
|
485
|
-
|
|
475
|
+
# session.visit 'https://reactjs.org/docs/forms.html'
|
|
476
|
+
# session.all(:css, 'h2#controlled-components ~ p a', text: 'Try it on CodePen')[0].click
|
|
477
|
+
# copied into local view
|
|
478
|
+
session.visit 'react'
|
|
479
|
+
# Not necessary when accessed locally
|
|
480
|
+
# session.within_frame(:css, 'iframe.result-iframe:not([src=""])', wait: 10) do
|
|
481
|
+
session.fill_in('Name:', with: 'abc')
|
|
482
|
+
session.accept_prompt 'A name was submitted: abc' do
|
|
483
|
+
session.click_button('Submit')
|
|
484
|
+
end
|
|
485
|
+
session.fill_in('Name:', with: '')
|
|
486
|
+
session.accept_prompt(/A name was submitted: $/) do
|
|
487
|
+
session.click_button('Submit')
|
|
486
488
|
end
|
|
489
|
+
# end
|
|
487
490
|
end
|
|
488
491
|
end
|
|
489
492
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -9,7 +9,8 @@ module Capybara
|
|
|
9
9
|
module SpecHelper
|
|
10
10
|
def firefox?(session)
|
|
11
11
|
browser_name(session) == :firefox &&
|
|
12
|
-
|
|
12
|
+
((defined?(::Selenium::WebDriver::VERSION) && (::Selenium::WebDriver::VERSION.to_f >= 4)) ||
|
|
13
|
+
session.driver.browser.capabilities.is_a?(::Selenium::WebDriver::Remote::W3C::Capabilities))
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def firefox_lt?(version, session)
|
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.17.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: 2019-
|
|
13
|
+
date: 2019-04-18 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: addressable
|
|
@@ -152,20 +152,6 @@ dependencies:
|
|
|
152
152
|
- - ">="
|
|
153
153
|
- !ruby/object:Gem::Version
|
|
154
154
|
version: '0'
|
|
155
|
-
- !ruby/object:Gem::Dependency
|
|
156
|
-
name: fuubar
|
|
157
|
-
requirement: !ruby/object:Gem::Requirement
|
|
158
|
-
requirements:
|
|
159
|
-
- - ">="
|
|
160
|
-
- !ruby/object:Gem::Version
|
|
161
|
-
version: 1.0.0
|
|
162
|
-
type: :development
|
|
163
|
-
prerelease: false
|
|
164
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
165
|
-
requirements:
|
|
166
|
-
- - ">="
|
|
167
|
-
- !ruby/object:Gem::Version
|
|
168
|
-
version: 1.0.0
|
|
169
155
|
- !ruby/object:Gem::Dependency
|
|
170
156
|
name: irb
|
|
171
157
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -407,6 +393,8 @@ files:
|
|
|
407
393
|
- lib/capybara/rack_test/form.rb
|
|
408
394
|
- lib/capybara/rack_test/node.rb
|
|
409
395
|
- lib/capybara/rails.rb
|
|
396
|
+
- lib/capybara/registrations/drivers.rb
|
|
397
|
+
- lib/capybara/registrations/servers.rb
|
|
410
398
|
- lib/capybara/result.rb
|
|
411
399
|
- lib/capybara/rspec.rb
|
|
412
400
|
- lib/capybara/rspec/features.rb
|
|
@@ -442,6 +430,7 @@ files:
|
|
|
442
430
|
- lib/capybara/selenium/extensions/find.rb
|
|
443
431
|
- lib/capybara/selenium/extensions/html5_drag.rb
|
|
444
432
|
- lib/capybara/selenium/extensions/scroll.rb
|
|
433
|
+
- lib/capybara/selenium/logger_suppressor.rb
|
|
445
434
|
- lib/capybara/selenium/node.rb
|
|
446
435
|
- lib/capybara/selenium/nodes/chrome_node.rb
|
|
447
436
|
- lib/capybara/selenium/nodes/firefox_node.rb
|
|
@@ -567,6 +556,7 @@ files:
|
|
|
567
556
|
- lib/capybara/spec/views/popup_one.erb
|
|
568
557
|
- lib/capybara/spec/views/popup_two.erb
|
|
569
558
|
- lib/capybara/spec/views/postback.erb
|
|
559
|
+
- lib/capybara/spec/views/react.erb
|
|
570
560
|
- lib/capybara/spec/views/scroll.erb
|
|
571
561
|
- lib/capybara/spec/views/tables.erb
|
|
572
562
|
- lib/capybara/spec/views/with_animation.erb
|