capybara 3.33.0 → 3.35.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +83 -15
- data/README.md +0 -2
- data/lib/capybara.rb +1 -1
- data/lib/capybara/config.rb +4 -6
- data/lib/capybara/driver/base.rb +4 -0
- data/lib/capybara/helpers.rb +25 -1
- data/lib/capybara/minitest.rb +2 -2
- data/lib/capybara/minitest/spec.rb +14 -11
- data/lib/capybara/node/actions.rb +1 -2
- data/lib/capybara/node/base.rb +6 -6
- data/lib/capybara/node/element.rb +1 -5
- data/lib/capybara/node/finders.rb +7 -6
- data/lib/capybara/node/matchers.rb +8 -6
- data/lib/capybara/node/simple.rb +5 -1
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/current_path_query.rb +14 -4
- data/lib/capybara/queries/selector_query.rb +32 -17
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +2 -2
- data/lib/capybara/rack_test/browser.rb +7 -3
- data/lib/capybara/rack_test/driver.rb +1 -0
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/rack_test/node.rb +1 -1
- data/lib/capybara/registration_container.rb +3 -3
- data/lib/capybara/registrations/drivers.rb +18 -12
- data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
- data/lib/capybara/registrations/servers.rb +2 -1
- data/lib/capybara/result.rb +6 -10
- data/lib/capybara/rspec.rb +2 -0
- data/lib/capybara/rspec/matcher_proxies.rb +1 -1
- data/lib/capybara/rspec/matchers.rb +7 -6
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/match_style.rb +5 -0
- data/lib/capybara/selector.rb +2 -2
- data/lib/capybara/selector/builders/css_builder.rb +1 -1
- data/lib/capybara/selector/builders/xpath_builder.rb +3 -1
- data/lib/capybara/selector/definition.rb +6 -5
- data/lib/capybara/selector/definition/button.rb +26 -15
- data/lib/capybara/selector/definition/css.rb +1 -1
- data/lib/capybara/selector/definition/datalist_input.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +2 -1
- data/lib/capybara/selector/definition/label.rb +1 -1
- data/lib/capybara/selector/definition/select.rb +1 -1
- data/lib/capybara/selector/definition/table_row.rb +2 -2
- data/lib/capybara/selector/filter_set.rb +2 -2
- data/lib/capybara/selector/selector.rb +5 -1
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
- data/lib/capybara/selenium/driver.rb +47 -5
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +3 -3
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +3 -3
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +1 -1
- data/lib/capybara/selenium/extensions/find.rb +4 -4
- data/lib/capybara/selenium/extensions/scroll.rb +8 -10
- data/lib/capybara/selenium/logger_suppressor.rb +8 -2
- data/lib/capybara/selenium/node.rb +6 -3
- data/lib/capybara/selenium/nodes/chrome_node.rb +23 -5
- data/lib/capybara/selenium/nodes/firefox_node.rb +6 -1
- data/lib/capybara/selenium/nodes/safari_node.rb +1 -1
- data/lib/capybara/selenium/patches/atoms.rb +4 -4
- data/lib/capybara/selenium/patches/logs.rb +4 -4
- data/lib/capybara/server/animation_disabler.rb +8 -3
- data/lib/capybara/server/middleware.rb +4 -2
- data/lib/capybara/session.rb +20 -11
- data/lib/capybara/session/matchers.rb +11 -11
- data/lib/capybara/spec/public/test.js +6 -1
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +6 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
- data/lib/capybara/spec/session/current_url_spec.rb +11 -1
- data/lib/capybara/spec/session/has_button_spec.rb +35 -0
- data/lib/capybara/spec/session/has_css_spec.rb +2 -1
- data/lib/capybara/spec/session/has_current_path_spec.rb +13 -0
- data/lib/capybara/spec/session/has_text_spec.rb +0 -11
- data/lib/capybara/spec/session/html_spec.rb +1 -1
- data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
- data/lib/capybara/spec/session/node_spec.rb +23 -3
- data/lib/capybara/spec/session/refresh_spec.rb +2 -1
- data/lib/capybara/spec/session/save_page_spec.rb +4 -4
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +11 -12
- data/lib/capybara/spec/test_app.rb +9 -3
- data/lib/capybara/spec/views/form.erb +23 -1
- data/lib/capybara/spec/views/with_animation.erb +8 -0
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +2 -0
- data/lib/capybara/spec/views/with_sortable_js.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +3 -7
- data/spec/basic_node_spec.rb +9 -8
- data/spec/dsl_spec.rb +1 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/minitest_spec.rb +2 -1
- data/spec/rack_test_spec.rb +15 -5
- data/spec/rspec/features_spec.rb +3 -1
- data/spec/rspec/scenarios_spec.rb +4 -0
- data/spec/rspec/shared_spec_matchers.rb +2 -2
- data/spec/rspec_spec.rb +4 -0
- data/spec/selector_spec.rb +16 -1
- data/spec/selenium_spec_chrome.rb +39 -18
- data/spec/selenium_spec_chrome_remote.rb +5 -1
- data/spec/selenium_spec_firefox.rb +15 -13
- data/spec/server_spec.rb +19 -0
- data/spec/shared_selenium_session.rb +74 -1
- metadata +47 -13
- data/lib/capybara/spec/session/source_spec.rb +0 -0
data/spec/server_spec.rb
CHANGED
@@ -99,6 +99,25 @@ RSpec.describe Capybara::Server do
|
|
99
99
|
expect(uri.to_hash).to include(scheme: 'http', host: server.host, port: server.port)
|
100
100
|
end
|
101
101
|
|
102
|
+
it 'should call #clamp on the puma configuration to ensure that environment is a string' do
|
103
|
+
Capybara.server = :puma
|
104
|
+
app_proc = proc { |_env| [200, {}, ['Hello Puma!']] }
|
105
|
+
require 'puma'
|
106
|
+
allow(Puma::Server).to receive(:new).and_wrap_original do |method, app, events, options|
|
107
|
+
# If #clamp is not called on the puma config then this will be a Proc
|
108
|
+
expect(options.fetch(:environment)).to be_a(String)
|
109
|
+
method.call(app, events, options)
|
110
|
+
end
|
111
|
+
server = described_class.new(app_proc).boot
|
112
|
+
expect(Puma::Server).to have_received(:new).with(
|
113
|
+
anything,
|
114
|
+
anything,
|
115
|
+
satisfy { |opts| opts.final_options[:Port] == server.port }
|
116
|
+
)
|
117
|
+
ensure
|
118
|
+
Capybara.server = :default
|
119
|
+
end
|
120
|
+
|
102
121
|
it 'should support SSL' do
|
103
122
|
key = File.join(Dir.pwd, 'spec', 'fixtures', 'key.pem')
|
104
123
|
cert = File.join(Dir.pwd, 'spec', 'fixtures', 'certificate.pem')
|
@@ -167,7 +167,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
167
167
|
long_string = (0...60).map { |i| ((i % 26) + 65).chr }.join
|
168
168
|
session.visit('/form')
|
169
169
|
session.fill_in('form_first_name', with: long_string, fill_options: { clear: :none })
|
170
|
-
expect(session.find(:fillable_field, 'form_first_name').value).to eq(
|
170
|
+
expect(session.find(:fillable_field, 'form_first_name').value).to eq("John#{long_string}")
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -214,6 +214,26 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
217
|
+
describe '#fill_in with Emoji' do
|
218
|
+
it 'sends emojis' do
|
219
|
+
session.visit('/form')
|
220
|
+
session.fill_in('form_first_name', with: 'a😀cd😴 🛌🏽🇵🇹 e🤾🏽♀️f')
|
221
|
+
expect(session.find(:fillable_field, 'form_first_name').value).to eq('a😀cd😴 🛌🏽🇵🇹 e🤾🏽♀️f')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
describe '#send_keys' do
|
226
|
+
it 'defaults to sending keys to the document.activeElement' do
|
227
|
+
session.visit('/form')
|
228
|
+
|
229
|
+
expect(session.evaluate_script('document.activeElement')).to eq(session.find('//body'))
|
230
|
+
|
231
|
+
session.send_keys(:tab)
|
232
|
+
|
233
|
+
expect(session.evaluate_script('document.activeElement')).to eq(session.first(:field))
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
217
237
|
describe '#path' do
|
218
238
|
it 'returns xpath' do
|
219
239
|
# this is here because it is testing for an XPath that is specific to the algorithm used in the selenium driver
|
@@ -369,15 +389,64 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
369
389
|
|
370
390
|
it 'should disable CSS animations (set to 0s)' do
|
371
391
|
@animation_session.visit('with_animation')
|
392
|
+
sleep 1
|
372
393
|
@animation_session.click_link('animate me away')
|
373
394
|
expect(@animation_session).to have_no_link('animate me away', wait: 0.5)
|
374
395
|
end
|
375
396
|
|
376
397
|
it 'should disable CSS animations on pseudo elements (set to 0s)' do
|
377
398
|
@animation_session.visit('with_animation')
|
399
|
+
sleep 1
|
378
400
|
@animation_session.find_link('animate me away').right_click
|
379
401
|
expect(@animation_session).to have_content('Animation Ended', wait: 0.1)
|
380
402
|
end
|
403
|
+
|
404
|
+
it 'should scroll the page instantly', requires: [:js] do
|
405
|
+
@animation_session.visit('with_animation')
|
406
|
+
scroll_y = @animation_session.evaluate_script(<<~JS)
|
407
|
+
(function(){
|
408
|
+
window.scrollTo(0,500);
|
409
|
+
return window.scrollY;
|
410
|
+
})()
|
411
|
+
JS
|
412
|
+
expect(scroll_y).to eq 500
|
413
|
+
end
|
414
|
+
|
415
|
+
it 'should scroll the page instantly without jquery animation', requires: [:js] do
|
416
|
+
@animation_session.visit('with_jquery_animation')
|
417
|
+
@animation_session.click_link('scroll top 500')
|
418
|
+
scroll_y = @animation_session.evaluate_script('window.scrollY')
|
419
|
+
expect(scroll_y).to eq 500
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
context 'when set to `false`' do
|
424
|
+
before(:context) do # rubocop:disable RSpec/BeforeAfterAll
|
425
|
+
skip "Safari doesn't support multiple sessions" if safari?(session)
|
426
|
+
# NOTE: Although Capybara.SpecHelper.reset! sets Capybara.disable_animation to false,
|
427
|
+
# it doesn't affect any of these tests because the settings are applied per-session
|
428
|
+
Capybara.disable_animation = false
|
429
|
+
@animation_session = Capybara::Session.new(session.mode, TestApp.new)
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'should scroll the page with a smooth animation', requires: [:js] do
|
433
|
+
@animation_session.visit('with_animation')
|
434
|
+
scroll_y = @animation_session.evaluate_script(<<~JS)
|
435
|
+
(function(){
|
436
|
+
window.scrollTo(0,500);
|
437
|
+
return window.scrollY;
|
438
|
+
})()
|
439
|
+
JS
|
440
|
+
# measured over 0.5 seconds: 0, 75, 282, 478, 500
|
441
|
+
expect(scroll_y).to be < 500
|
442
|
+
end
|
443
|
+
|
444
|
+
it 'should scroll the page with jquery animation', requires: [:js] do
|
445
|
+
@animation_session.visit('with_jquery_animation')
|
446
|
+
@animation_session.click_link('scroll top 500')
|
447
|
+
scroll_y = @animation_session.evaluate_script('window.scrollY')
|
448
|
+
expect(scroll_y).to be < 500
|
449
|
+
end
|
381
450
|
end
|
382
451
|
|
383
452
|
context 'if we pass in css that matches elements' do
|
@@ -391,12 +460,14 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
391
460
|
|
392
461
|
it 'should disable CSS transitions' do
|
393
462
|
@animation_session_with_matching_css.visit('with_animation')
|
463
|
+
sleep 1
|
394
464
|
@animation_session_with_matching_css.click_link('transition me away')
|
395
465
|
expect(@animation_session_with_matching_css).to have_no_link('transition me away', wait: 0.5)
|
396
466
|
end
|
397
467
|
|
398
468
|
it 'should disable CSS animations' do
|
399
469
|
@animation_session_with_matching_css.visit('with_animation')
|
470
|
+
sleep 1
|
400
471
|
@animation_session_with_matching_css.click_link('animate me away')
|
401
472
|
expect(@animation_session_with_matching_css).to have_no_link('animate me away', wait: 0.5)
|
402
473
|
end
|
@@ -413,6 +484,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
413
484
|
|
414
485
|
it 'should not disable CSS transitions' do
|
415
486
|
@animation_session_without_matching_css.visit('with_animation')
|
487
|
+
sleep 1
|
416
488
|
@animation_session_without_matching_css.click_link('transition me away')
|
417
489
|
sleep 0.5 # Wait long enough for click to have been processed
|
418
490
|
expect(@animation_session_without_matching_css).to have_link('transition me away', wait: false)
|
@@ -421,6 +493,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
421
493
|
|
422
494
|
it 'should not disable CSS animations' do
|
423
495
|
@animation_session_without_matching_css.visit('with_animation')
|
496
|
+
sleep 1
|
424
497
|
@animation_session_without_matching_css.click_link('animate me away')
|
425
498
|
sleep 0.5 # Wait long enough for click to have been processed
|
426
499
|
expect(@animation_session_without_matching_css).to have_link('animate me away', wait: false)
|
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.35.3
|
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:
|
13
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -86,16 +86,22 @@ dependencies:
|
|
86
86
|
name: regexp_parser
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - "
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '1.5'
|
92
|
+
- - "<"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '3.0'
|
92
95
|
type: :runtime
|
93
96
|
prerelease: false
|
94
97
|
version_requirements: !ruby/object:Gem::Requirement
|
95
98
|
requirements:
|
96
|
-
- - "
|
99
|
+
- - ">="
|
97
100
|
- !ruby/object:Gem::Version
|
98
101
|
version: '1.5'
|
102
|
+
- - "<"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3.0'
|
99
105
|
- !ruby/object:Gem::Dependency
|
100
106
|
name: xpath
|
101
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,16 +276,16 @@ dependencies:
|
|
270
276
|
requirements:
|
271
277
|
- - "~>"
|
272
278
|
- !ruby/object:Gem::Version
|
273
|
-
version: '
|
279
|
+
version: '1.1'
|
274
280
|
type: :development
|
275
281
|
prerelease: false
|
276
282
|
version_requirements: !ruby/object:Gem::Requirement
|
277
283
|
requirements:
|
278
284
|
- - "~>"
|
279
285
|
- !ruby/object:Gem::Version
|
280
|
-
version: '
|
286
|
+
version: '1.1'
|
281
287
|
- !ruby/object:Gem::Dependency
|
282
|
-
name: rubocop-
|
288
|
+
name: rubocop-minitest
|
283
289
|
requirement: !ruby/object:Gem::Requirement
|
284
290
|
requirements:
|
285
291
|
- - ">="
|
@@ -293,7 +299,7 @@ dependencies:
|
|
293
299
|
- !ruby/object:Gem::Version
|
294
300
|
version: '0'
|
295
301
|
- !ruby/object:Gem::Dependency
|
296
|
-
name: rubocop-
|
302
|
+
name: rubocop-performance
|
297
303
|
requirement: !ruby/object:Gem::Requirement
|
298
304
|
requirements:
|
299
305
|
- - ">="
|
@@ -307,7 +313,7 @@ dependencies:
|
|
307
313
|
- !ruby/object:Gem::Version
|
308
314
|
version: '0'
|
309
315
|
- !ruby/object:Gem::Dependency
|
310
|
-
name:
|
316
|
+
name: rubocop-rake
|
311
317
|
requirement: !ruby/object:Gem::Requirement
|
312
318
|
requirements:
|
313
319
|
- - ">="
|
@@ -321,19 +327,33 @@ dependencies:
|
|
321
327
|
- !ruby/object:Gem::Version
|
322
328
|
version: '0'
|
323
329
|
- !ruby/object:Gem::Dependency
|
324
|
-
name:
|
330
|
+
name: rubocop-rspec
|
325
331
|
requirement: !ruby/object:Gem::Requirement
|
326
332
|
requirements:
|
327
333
|
- - "~>"
|
328
334
|
- !ruby/object:Gem::Version
|
329
|
-
version: '
|
335
|
+
version: '2.0'
|
330
336
|
type: :development
|
331
337
|
prerelease: false
|
332
338
|
version_requirements: !ruby/object:Gem::Requirement
|
333
339
|
requirements:
|
334
340
|
- - "~>"
|
335
341
|
- !ruby/object:Gem::Version
|
336
|
-
version: '
|
342
|
+
version: '2.0'
|
343
|
+
- !ruby/object:Gem::Dependency
|
344
|
+
name: sauce_whisk
|
345
|
+
requirement: !ruby/object:Gem::Requirement
|
346
|
+
requirements:
|
347
|
+
- - ">="
|
348
|
+
- !ruby/object:Gem::Version
|
349
|
+
version: '0'
|
350
|
+
type: :development
|
351
|
+
prerelease: false
|
352
|
+
version_requirements: !ruby/object:Gem::Requirement
|
353
|
+
requirements:
|
354
|
+
- - ">="
|
355
|
+
- !ruby/object:Gem::Version
|
356
|
+
version: '0'
|
337
357
|
- !ruby/object:Gem::Dependency
|
338
358
|
name: selenium_statistics
|
339
359
|
requirement: !ruby/object:Gem::Requirement
|
@@ -348,6 +368,20 @@ dependencies:
|
|
348
368
|
- - ">="
|
349
369
|
- !ruby/object:Gem::Version
|
350
370
|
version: '0'
|
371
|
+
- !ruby/object:Gem::Dependency
|
372
|
+
name: selenium-webdriver
|
373
|
+
requirement: !ruby/object:Gem::Requirement
|
374
|
+
requirements:
|
375
|
+
- - "~>"
|
376
|
+
- !ruby/object:Gem::Version
|
377
|
+
version: '3.5'
|
378
|
+
type: :development
|
379
|
+
prerelease: false
|
380
|
+
version_requirements: !ruby/object:Gem::Requirement
|
381
|
+
requirements:
|
382
|
+
- - "~>"
|
383
|
+
- !ruby/object:Gem::Version
|
384
|
+
version: '3.5'
|
351
385
|
- !ruby/object:Gem::Dependency
|
352
386
|
name: sinatra
|
353
387
|
requirement: !ruby/object:Gem::Requirement
|
@@ -625,7 +659,6 @@ files:
|
|
625
659
|
- lib/capybara/spec/session/select_spec.rb
|
626
660
|
- lib/capybara/spec/session/selectors_spec.rb
|
627
661
|
- lib/capybara/spec/session/sibling_spec.rb
|
628
|
-
- lib/capybara/spec/session/source_spec.rb
|
629
662
|
- lib/capybara/spec/session/text_spec.rb
|
630
663
|
- lib/capybara/spec/session/title_spec.rb
|
631
664
|
- lib/capybara/spec/session/uncheck_spec.rb
|
@@ -673,6 +706,7 @@ files:
|
|
673
706
|
- lib/capybara/spec/views/with_html.erb
|
674
707
|
- lib/capybara/spec/views/with_html5_svg.erb
|
675
708
|
- lib/capybara/spec/views/with_html_entities.erb
|
709
|
+
- lib/capybara/spec/views/with_jquery_animation.erb
|
676
710
|
- lib/capybara/spec/views/with_js.erb
|
677
711
|
- lib/capybara/spec/views/with_jstree.erb
|
678
712
|
- lib/capybara/spec/views/with_namespace.erb
|
File without changes
|