capybara 3.29.0 → 3.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +19 -1
- data/README.md +1 -1
- data/lib/capybara/config.rb +7 -3
- data/lib/capybara/helpers.rb +3 -1
- data/lib/capybara/node/actions.rb +23 -19
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +3 -3
- data/lib/capybara/node/element.rb +10 -8
- data/lib/capybara/node/finders.rb +12 -10
- data/lib/capybara/node/matchers.rb +39 -33
- data/lib/capybara/node/simple.rb +3 -1
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/selector_query.rb +17 -4
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/rack_test/browser.rb +4 -1
- data/lib/capybara/rack_test/driver.rb +1 -1
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/selector.rb +22 -16
- data/lib/capybara/selector/css.rb +1 -1
- data/lib/capybara/selector/definition.rb +2 -2
- data/lib/capybara/selector/definition/button.rb +7 -2
- data/lib/capybara/selector/definition/checkbox.rb +2 -2
- data/lib/capybara/selector/definition/css.rb +3 -1
- data/lib/capybara/selector/definition/datalist_input.rb +1 -1
- data/lib/capybara/selector/definition/datalist_option.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +1 -1
- data/lib/capybara/selector/definition/field.rb +1 -1
- data/lib/capybara/selector/definition/file_field.rb +1 -1
- data/lib/capybara/selector/definition/fillable_field.rb +1 -1
- data/lib/capybara/selector/definition/label.rb +3 -1
- data/lib/capybara/selector/definition/radio_button.rb +2 -2
- data/lib/capybara/selector/definition/select.rb +1 -1
- data/lib/capybara/selector/definition/table.rb +5 -2
- data/lib/capybara/selector/filter_set.rb +11 -9
- data/lib/capybara/selector/filters/base.rb +6 -1
- data/lib/capybara/selector/filters/locator_filter.rb +1 -1
- data/lib/capybara/selector/selector.rb +4 -2
- data/lib/capybara/selenium/driver.rb +19 -11
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -2
- data/lib/capybara/selenium/extensions/html5_drag.rb +6 -5
- data/lib/capybara/selenium/node.rb +6 -4
- data/lib/capybara/selenium/nodes/chrome_node.rb +7 -3
- data/lib/capybara/selenium/nodes/edge_node.rb +3 -1
- data/lib/capybara/selenium/nodes/firefox_node.rb +1 -1
- data/lib/capybara/server.rb +15 -3
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +20 -10
- data/lib/capybara/session.rb +10 -8
- data/lib/capybara/session/config.rb +6 -2
- data/lib/capybara/session/matchers.rb +6 -6
- data/lib/capybara/spec/public/test.js +11 -0
- data/lib/capybara/spec/session/all_spec.rb +15 -0
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_text_spec.rb +4 -0
- data/lib/capybara/spec/session/click_button_spec.rb +5 -0
- data/lib/capybara/spec/session/find_spec.rb +20 -0
- data/lib/capybara/spec/session/has_table_spec.rb +51 -5
- data/lib/capybara/spec/session/has_text_spec.rb +31 -0
- data/lib/capybara/spec/session/node_spec.rb +15 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
- data/lib/capybara/spec/session/selectors_spec.rb +15 -2
- data/lib/capybara/spec/views/form.erb +5 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/dsl_spec.rb +2 -2
- data/spec/minitest_spec_spec.rb +46 -46
- data/spec/regexp_dissassembler_spec.rb +45 -37
- data/spec/result_spec.rb +3 -3
- data/spec/rspec/features_spec.rb +1 -0
- data/spec/rspec/shared_spec_matchers.rb +3 -3
- data/spec/rspec_spec.rb +4 -4
- data/spec/selenium_spec_chrome.rb +3 -3
- data/spec/selenium_spec_firefox.rb +7 -2
- data/spec/server_spec.rb +42 -0
- data/spec/session_spec.rb +1 -1
- data/spec/shared_selenium_node.rb +3 -3
- data/spec/shared_selenium_session.rb +8 -7
- metadata +3 -3
data/spec/rspec_spec.rb
CHANGED
@@ -43,7 +43,7 @@ RSpec.describe 'capybara/rspec' do
|
|
43
43
|
expect(Capybara.current_driver).to eq(:culerity)
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
describe '#all' do
|
47
47
|
it 'allows access to the Capybara finder' do
|
48
48
|
visit('/with_html')
|
49
49
|
found = all(:css, 'h2') { |element| element[:class] == 'head' }
|
@@ -57,7 +57,7 @@ RSpec.describe 'capybara/rspec' do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
describe '#within' do
|
61
61
|
it 'allows access to the Capybara scoper' do
|
62
62
|
visit('/with_html')
|
63
63
|
expect do
|
@@ -82,7 +82,7 @@ RSpec.describe 'capybara/rspec' do
|
|
82
82
|
end.new
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
describe '#all' do
|
86
86
|
it 'allows access to the Capybara finder' do
|
87
87
|
test_class_instance.visit('/with_html')
|
88
88
|
expect(test_class_instance.all(:css, 'h2.head').size).to eq(5)
|
@@ -95,7 +95,7 @@ RSpec.describe 'capybara/rspec' do
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
describe '#within' do
|
99
99
|
it 'allows access to the Capybara scoper' do
|
100
100
|
test_class_instance.visit('/with_html')
|
101
101
|
expect do
|
@@ -29,7 +29,7 @@ Capybara.register_driver :selenium_chrome_not_clear_storage do |app|
|
|
29
29
|
browser: :chrome,
|
30
30
|
options: browser_options
|
31
31
|
}
|
32
|
-
Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_local_storage: false, clear_session_storage: false))
|
32
|
+
Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_local_storage: false, clear_session_storage: false))
|
33
33
|
end
|
34
34
|
|
35
35
|
Capybara.register_driver :selenium_chrome_not_clear_session_storage do |app|
|
@@ -37,7 +37,7 @@ Capybara.register_driver :selenium_chrome_not_clear_session_storage do |app|
|
|
37
37
|
browser: :chrome,
|
38
38
|
options: browser_options
|
39
39
|
}
|
40
|
-
Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_session_storage: false))
|
40
|
+
Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_session_storage: false))
|
41
41
|
end
|
42
42
|
|
43
43
|
Capybara.register_driver :selenium_chrome_not_clear_local_storage do |app|
|
@@ -45,7 +45,7 @@ Capybara.register_driver :selenium_chrome_not_clear_local_storage do |app|
|
|
45
45
|
browser: :chrome,
|
46
46
|
options: browser_options
|
47
47
|
}
|
48
|
-
Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_local_storage: false))
|
48
|
+
Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_local_storage: false))
|
49
49
|
end
|
50
50
|
|
51
51
|
Capybara.register_driver :selenium_driver_subclass_with_chrome do |app|
|
@@ -49,7 +49,7 @@ Capybara::SpecHelper.log_selenium_driver_version(Selenium::WebDriver::Firefox) i
|
|
49
49
|
Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capybara_skip: skipped_tests do |example|
|
50
50
|
case example.metadata[:full_description]
|
51
51
|
when 'Capybara::Session selenium node #click should allow multiple modifiers'
|
52
|
-
pending "Firefox doesn't generate an event for shift+control+click" if firefox_gte?(62, @session) &&
|
52
|
+
pending "Firefox on OSX doesn't generate an event for shift+control+click" if firefox_gte?(62, @session) && Selenium::WebDriver::Platform.mac?
|
53
53
|
when /^Capybara::Session selenium node #double_click/
|
54
54
|
pending "selenium-webdriver/geckodriver doesn't generate double click event" if firefox_lt?(59, @session)
|
55
55
|
when 'Capybara::Session selenium #accept_prompt should accept the prompt with a blank response when there is a default'
|
@@ -58,12 +58,17 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capyba
|
|
58
58
|
pending "FF < 62 doesn't support setting all files at once" if firefox_lt?(62, @session)
|
59
59
|
when 'Capybara::Session selenium #accept_confirm should work with nested modals'
|
60
60
|
skip 'Broken in 63 <= FF < 69 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if firefox_gte?(63, @session) && firefox_lt?(69, @session)
|
61
|
+
skip 'Hangs in 69 <= FF < 71 - Dont know what issue for this - previous issue was closed as fixed but it is not' if firefox_gte?(69, @session) && firefox_lt?(71, @session)
|
62
|
+
skip 'Broken again intermittently in FF 71 - jus skip it'
|
61
63
|
when 'Capybara::Session selenium #click_link can download a file'
|
62
64
|
skip 'Need to figure out testing of file downloading on windows platform' if Gem.win_platform?
|
63
65
|
when 'Capybara::Session selenium #reset_session! removes ALL cookies'
|
64
66
|
pending "Geckodriver doesn't provide a way to remove cookies outside the current domain"
|
65
67
|
when /drag_to.*HTML5/
|
66
68
|
pending "Firefox < 62 doesn't support a DataTransfer constuctor" if firefox_lt?(62.0, @session)
|
69
|
+
when 'Capybara::Session selenium #accept_alert should handle the alert if the page changes',
|
70
|
+
'Capybara::Session selenium #accept_alert with an asynchronous alert should accept the alert'
|
71
|
+
skip 'No clue what Firefox is doing here - works fine on MacOS locally'
|
67
72
|
end
|
68
73
|
end
|
69
74
|
|
@@ -181,7 +186,7 @@ RSpec.describe Capybara::Selenium::Driver do
|
|
181
186
|
end
|
182
187
|
|
183
188
|
RSpec.describe Capybara::Selenium::Node do
|
184
|
-
|
189
|
+
describe '#click' do
|
185
190
|
it 'warns when attempting on a table row' do
|
186
191
|
session = TestSessions::SeleniumFirefox
|
187
192
|
session.visit('/tables')
|
data/spec/server_spec.rb
CHANGED
@@ -74,6 +74,28 @@ RSpec.describe Capybara::Server do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
it 'should handle that getting available ports fails randomly' do
|
78
|
+
begin
|
79
|
+
# Use a port to force a EADDRINUSE error to be generated
|
80
|
+
server = TCPServer.new('0.0.0.0', 0)
|
81
|
+
server_port = server.addr[1]
|
82
|
+
d_server = instance_double('TCPServer', addr: [nil, server_port, nil, nil], close: nil)
|
83
|
+
call_count = 0
|
84
|
+
allow(TCPServer).to receive(:new).and_wrap_original do |m, *args|
|
85
|
+
begin
|
86
|
+
call_count.zero? ? d_server : m.call(*args)
|
87
|
+
ensure
|
88
|
+
call_count += 1
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
port = described_class.new(Object.new, host: '0.0.0.0').port
|
93
|
+
expect(port).not_to eq(server_port)
|
94
|
+
ensure
|
95
|
+
server&.close
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
77
99
|
it 'should return its #base_url' do
|
78
100
|
app = proc { |_env| [200, {}, ['Hello Server!']] }
|
79
101
|
server = described_class.new(app).boot
|
@@ -217,6 +239,26 @@ RSpec.describe Capybara::Server do
|
|
217
239
|
end
|
218
240
|
end
|
219
241
|
|
242
|
+
it 'should raise an error when there are pending requests' do
|
243
|
+
app = proc do |env|
|
244
|
+
request = Rack::Request.new(env)
|
245
|
+
sleep request.params['wait_time'].to_f
|
246
|
+
[200, {}, ['Hello Server!']]
|
247
|
+
end
|
248
|
+
|
249
|
+
server = described_class.new(app).boot
|
250
|
+
|
251
|
+
expect do
|
252
|
+
start_request(server, 59.0)
|
253
|
+
server.wait_for_pending_requests
|
254
|
+
end.not_to raise_error
|
255
|
+
|
256
|
+
expect do
|
257
|
+
start_request(server, 61.0)
|
258
|
+
server.wait_for_pending_requests
|
259
|
+
end.to raise_error('Requests did not finish in 60 seconds: ["/?wait_time=61.0"]')
|
260
|
+
end
|
261
|
+
|
220
262
|
it 'is not #responsive? when Net::HTTP raises a SystemCallError' do
|
221
263
|
app = -> { [200, {}, ['Hello, world']] }
|
222
264
|
server = described_class.new(app)
|
data/spec/session_spec.rb
CHANGED
@@ -6,7 +6,7 @@ require 'selenium-webdriver'
|
|
6
6
|
RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
7
7
|
let(:session) { session }
|
8
8
|
|
9
|
-
|
9
|
+
describe '#content_editable?' do
|
10
10
|
it 'returns true when the element is content editable' do
|
11
11
|
session.visit('/with_js')
|
12
12
|
expect(session.find(:css, '#existing_content_editable').base.content_editable?).to be true
|
@@ -19,7 +19,7 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
describe '#send_keys' do
|
23
23
|
it 'should process space' do
|
24
24
|
session.visit('/form')
|
25
25
|
session.find(:css, '#address1_city').send_keys('ocean', [:shift, :space, 'side'])
|
@@ -27,7 +27,7 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
describe '#visible?' do
|
31
31
|
let(:bridge) do
|
32
32
|
session.driver.browser.send(:bridge)
|
33
33
|
end
|
@@ -72,7 +72,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
|
75
|
+
describe '#fill_in_with empty string and no options' do
|
76
76
|
it 'should trigger change when clearing a field' do
|
77
77
|
pending "safaridriver doesn't trigger change for clear" if safari?(session)
|
78
78
|
session.visit('/with_js')
|
@@ -83,7 +83,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
describe '#fill_in with { :clear => :backspace } fill_option', requires: [:js] do
|
87
87
|
before do
|
88
88
|
# Firefox has an issue with change events if the main window doesn't think it's focused
|
89
89
|
session.execute_script('window.focus()')
|
@@ -150,7 +150,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
|
153
|
+
describe '#fill_in with { clear: :none } fill_options' do
|
154
154
|
it 'should append to content in a field' do
|
155
155
|
pending 'Safari overwrites by default - need to figure out a workaround' if safari?(session)
|
156
156
|
|
@@ -162,7 +162,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
|
165
|
+
describe '#fill_in with Date' do
|
166
166
|
before do
|
167
167
|
session.visit('/form')
|
168
168
|
session.find(:css, '#form_date').execute_script <<-JS
|
@@ -194,7 +194,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
|
197
|
+
describe '#fill_in with { clear: Array } fill_options' do
|
198
198
|
it 'should pass the array through to the element' do
|
199
199
|
# this is mainly for use with [[:control, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
|
200
200
|
session.visit('/form')
|
@@ -299,8 +299,9 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
299
299
|
describe 'Element#click' do
|
300
300
|
it 'should handle fixed headers/footers' do
|
301
301
|
session.visit('/with_fixed_header_footer')
|
302
|
-
|
303
|
-
|
302
|
+
session.using_wait_time(2) do
|
303
|
+
session.find(:link, 'Go to root').click
|
304
|
+
end
|
304
305
|
expect(session).to have_current_path('/')
|
305
306
|
end
|
306
307
|
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.30.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-12-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -744,7 +744,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
744
744
|
- !ruby/object:Gem::Version
|
745
745
|
version: '0'
|
746
746
|
requirements: []
|
747
|
-
rubygems_version: 3.
|
747
|
+
rubygems_version: 3.1.2
|
748
748
|
signing_key:
|
749
749
|
specification_version: 4
|
750
750
|
summary: Capybara aims to simplify the process of integration testing Rack applications,
|