capybara 3.29.0 → 3.37.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +229 -15
- data/README.md +13 -4
- data/lib/capybara/config.rb +24 -10
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/base.rb +8 -0
- data/lib/capybara/driver/node.rb +5 -1
- data/lib/capybara/dsl.rb +5 -3
- data/lib/capybara/helpers.rb +19 -2
- data/lib/capybara/minitest/spec.rb +156 -97
- data/lib/capybara/minitest.rb +232 -144
- data/lib/capybara/node/actions.rb +41 -37
- data/lib/capybara/node/base.rb +6 -6
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +3 -3
- data/lib/capybara/node/element.rb +35 -21
- data/lib/capybara/node/finders.rb +33 -19
- data/lib/capybara/node/matchers.rb +72 -57
- data/lib/capybara/node/simple.rb +13 -3
- data/lib/capybara/queries/active_element_query.rb +18 -0
- data/lib/capybara/queries/ancestor_query.rb +4 -3
- data/lib/capybara/queries/base_query.rb +2 -1
- data/lib/capybara/queries/current_path_query.rb +14 -4
- data/lib/capybara/queries/selector_query.rb +91 -30
- data/lib/capybara/queries/sibling_query.rb +4 -3
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +7 -1
- data/lib/capybara/rack_test/browser.rb +68 -10
- data/lib/capybara/rack_test/driver.rb +6 -5
- data/lib/capybara/rack_test/form.rb +2 -2
- data/lib/capybara/rack_test/node.rb +44 -16
- data/lib/capybara/registration_container.rb +41 -0
- data/lib/capybara/registrations/drivers.rb +18 -12
- data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
- data/lib/capybara/registrations/servers.rb +3 -2
- data/lib/capybara/result.rb +35 -15
- data/lib/capybara/rspec/matcher_proxies.rb +8 -8
- data/lib/capybara/rspec/matchers/base.rb +12 -6
- data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
- data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/have_selector.rb +16 -8
- data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
- data/lib/capybara/rspec/matchers/have_text.rb +3 -3
- data/lib/capybara/rspec/matchers/have_title.rb +2 -2
- data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
- data/lib/capybara/rspec/matchers/match_style.rb +7 -2
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
- data/lib/capybara/rspec/matchers.rb +33 -32
- data/lib/capybara/rspec.rb +2 -0
- data/lib/capybara/selector/builders/css_builder.rb +2 -2
- data/lib/capybara/selector/builders/xpath_builder.rb +4 -2
- data/lib/capybara/selector/css.rb +2 -2
- data/lib/capybara/selector/definition/button.rb +35 -13
- data/lib/capybara/selector/definition/checkbox.rb +3 -3
- data/lib/capybara/selector/definition/css.rb +3 -1
- data/lib/capybara/selector/definition/datalist_input.rb +2 -2
- data/lib/capybara/selector/definition/datalist_option.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +3 -2
- data/lib/capybara/selector/definition/field.rb +1 -1
- data/lib/capybara/selector/definition/file_field.rb +2 -2
- data/lib/capybara/selector/definition/fillable_field.rb +3 -3
- data/lib/capybara/selector/definition/label.rb +5 -3
- data/lib/capybara/selector/definition/link.rb +8 -0
- data/lib/capybara/selector/definition/radio_button.rb +3 -3
- data/lib/capybara/selector/definition/select.rb +33 -14
- data/lib/capybara/selector/definition/table.rb +6 -3
- data/lib/capybara/selector/definition/table_row.rb +2 -2
- data/lib/capybara/selector/definition.rb +15 -11
- data/lib/capybara/selector/filter_set.rb +17 -17
- 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 +17 -3
- data/lib/capybara/selector.rb +37 -19
- data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
- data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
- data/lib/capybara/selenium/driver.rb +84 -17
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +11 -13
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +10 -12
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +4 -4
- data/lib/capybara/selenium/extensions/find.rb +4 -4
- data/lib/capybara/selenium/extensions/html5_drag.rb +30 -13
- data/lib/capybara/selenium/extensions/scroll.rb +8 -10
- data/lib/capybara/selenium/logger_suppressor.rb +8 -2
- data/lib/capybara/selenium/node.rb +122 -26
- data/lib/capybara/selenium/nodes/chrome_node.rb +34 -19
- data/lib/capybara/selenium/nodes/edge_node.rb +5 -3
- data/lib/capybara/selenium/nodes/firefox_node.rb +11 -6
- data/lib/capybara/selenium/nodes/safari_node.rb +3 -3
- data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
- data/lib/capybara/selenium/patches/atoms.rb +4 -4
- data/lib/capybara/selenium/patches/logs.rb +7 -9
- data/lib/capybara/server/animation_disabler.rb +38 -15
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +22 -10
- data/lib/capybara/server.rb +15 -3
- data/lib/capybara/session/config.rb +10 -4
- data/lib/capybara/session/matchers.rb +11 -11
- data/lib/capybara/session.rb +62 -39
- data/lib/capybara/spec/public/test.js +75 -7
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
- data/lib/capybara/spec/session/active_element_spec.rb +31 -0
- data/lib/capybara/spec/session/all_spec.rb +63 -12
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_text_spec.rb +26 -22
- data/lib/capybara/spec/session/check_spec.rb +15 -0
- data/lib/capybara/spec/session/choose_spec.rb +6 -0
- data/lib/capybara/spec/session/click_button_spec.rb +16 -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/fill_in_spec.rb +29 -0
- data/lib/capybara/spec/session/find_spec.rb +37 -8
- data/lib/capybara/spec/session/has_any_selectors_spec.rb +4 -0
- data/lib/capybara/spec/session/has_button_spec.rb +75 -0
- data/lib/capybara/spec/session/has_css_spec.rb +14 -10
- data/lib/capybara/spec/session/has_current_path_spec.rb +17 -4
- data/lib/capybara/spec/session/has_field_spec.rb +41 -1
- data/lib/capybara/spec/session/has_link_spec.rb +30 -0
- data/lib/capybara/spec/session/has_select_spec.rb +36 -8
- data/lib/capybara/spec/session/has_selector_spec.rb +19 -4
- data/lib/capybara/spec/session/has_table_spec.rb +51 -5
- data/lib/capybara/spec/session/has_text_spec.rb +21 -1
- 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 +226 -33
- data/lib/capybara/spec/session/refresh_spec.rb +2 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_page_spec.rb +4 -4
- data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
- data/lib/capybara/spec/session/scroll_spec.rb +4 -4
- data/lib/capybara/spec/session/selectors_spec.rb +15 -2
- data/lib/capybara/spec/session/visit_spec.rb +20 -0
- 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 +9 -9
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +17 -17
- data/lib/capybara/spec/test_app.rb +89 -29
- data/lib/capybara/spec/views/animated.erb +1 -1
- data/lib/capybara/spec/views/form.erb +52 -6
- data/lib/capybara/spec/views/frame_child.erb +1 -1
- data/lib/capybara/spec/views/frame_one.erb +1 -1
- data/lib/capybara/spec/views/frame_parent.erb +1 -1
- data/lib/capybara/spec/views/frame_two.erb +1 -1
- data/lib/capybara/spec/views/initial_alert.erb +2 -1
- data/lib/capybara/spec/views/layout.erb +10 -0
- data/lib/capybara/spec/views/obscured.erb +1 -1
- data/lib/capybara/spec/views/offset.erb +2 -1
- data/lib/capybara/spec/views/path.erb +2 -2
- data/lib/capybara/spec/views/popup_one.erb +1 -1
- data/lib/capybara/spec/views/popup_two.erb +1 -1
- data/lib/capybara/spec/views/react.erb +2 -2
- data/lib/capybara/spec/views/scroll.erb +2 -1
- data/lib/capybara/spec/views/spatial.erb +1 -1
- data/lib/capybara/spec/views/with_animation.erb +10 -3
- data/lib/capybara/spec/views/with_base_tag.erb +2 -2
- data/lib/capybara/spec/views/with_dragula.erb +5 -3
- data/lib/capybara/spec/views/with_fixed_header_footer.erb +2 -1
- data/lib/capybara/spec/views/with_hover.erb +2 -2
- data/lib/capybara/spec/views/with_html.erb +3 -3
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +5 -3
- data/lib/capybara/spec/views/with_jstree.erb +1 -1
- data/lib/capybara/spec/views/with_namespace.erb +1 -0
- data/lib/capybara/spec/views/with_shadow.erb +31 -0
- data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
- data/lib/capybara/spec/views/with_sortable_js.erb +3 -3
- data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
- data/lib/capybara/spec/views/with_windows.erb +1 -1
- data/lib/capybara/spec/views/within_frames.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +4 -8
- data/lib/capybara.rb +36 -29
- data/spec/basic_node_spec.rb +25 -11
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +18 -5
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
- data/spec/fixtures/selenium_driver_rspec_success.rb +3 -3
- data/spec/minitest_spec.rb +3 -2
- data/spec/minitest_spec_spec.rb +46 -46
- data/spec/rack_test_spec.rb +43 -11
- data/spec/regexp_dissassembler_spec.rb +40 -36
- data/spec/result_spec.rb +53 -45
- data/spec/rspec/features_spec.rb +7 -4
- data/spec/rspec/scenarios_spec.rb +5 -1
- data/spec/rspec/shared_spec_matchers.rb +68 -56
- data/spec/rspec_spec.rb +8 -4
- data/spec/sauce_spec_chrome.rb +3 -3
- data/spec/selector_spec.rb +19 -4
- data/spec/selenium_spec_chrome.rb +49 -26
- data/spec/selenium_spec_chrome_remote.rb +13 -6
- data/spec/selenium_spec_firefox.rb +29 -17
- data/spec/selenium_spec_firefox_remote.rb +2 -2
- data/spec/selenium_spec_ie.rb +3 -6
- data/spec/selenium_spec_safari.rb +31 -19
- data/spec/server_spec.rb +88 -35
- data/spec/session_spec.rb +1 -1
- data/spec/shared_selenium_node.rb +21 -7
- data/spec/shared_selenium_session.rb +123 -21
- data/spec/spec_helper.rb +2 -2
- metadata +80 -21
- data/lib/capybara/spec/session/source_spec.rb +0 -0
- data/lib/capybara/spec/views/with_title.erb +0 -5
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -270,13 +270,13 @@ Capybara::SpecHelper.spec 'node' do
|
|
270
270
|
end
|
271
271
|
|
272
272
|
it 'works when details is toggled open and closed' do
|
273
|
-
@session.find(:css, '#closed_details').click
|
274
|
-
expect(@session).to have_css('#closed_details *', visible:
|
273
|
+
@session.find(:css, '#closed_details > summary').click
|
274
|
+
expect(@session).to have_css('#closed_details *', visible: :visible, count: 5)
|
275
275
|
.and(have_no_css('#closed_details *', visible: :hidden))
|
276
276
|
|
277
|
-
@session.find(:css, '#closed_details').click
|
277
|
+
@session.find(:css, '#closed_details > summary').click
|
278
278
|
descendants_css = '#closed_details > *:not(summary), #closed_details > *:not(summary) *'
|
279
|
-
expect(@session).to have_no_css(descendants_css, visible:
|
279
|
+
expect(@session).to have_no_css(descendants_css, visible: :visible)
|
280
280
|
.and(have_css(descendants_css, visible: :hidden, count: 3))
|
281
281
|
end
|
282
282
|
end
|
@@ -388,8 +388,8 @@ Capybara::SpecHelper.spec 'node' do
|
|
388
388
|
|
389
389
|
describe '#==' do
|
390
390
|
it 'preserve object identity' do
|
391
|
-
expect(@session.find('//h1') == @session.find('//h1')).to be true # rubocop:disable Lint/
|
392
|
-
expect(@session.find('//h1') === @session.find('//h1')).to be true # rubocop:disable Style/CaseEquality, Lint/
|
391
|
+
expect(@session.find('//h1') == @session.find('//h1')).to be true # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
|
392
|
+
expect(@session.find('//h1') === @session.find('//h1')).to be true # rubocop:disable Style/CaseEquality, Lint/BinaryOperatorWithIdenticalOperands
|
393
393
|
expect(@session.find('//h1').eql?(@session.find('//h1'))).to be false
|
394
394
|
end
|
395
395
|
|
@@ -409,6 +409,17 @@ Capybara::SpecHelper.spec 'node' do
|
|
409
409
|
element = @session.find(:link, 'Second Link')
|
410
410
|
expect(@session.find(:xpath, element.path)).to eq(element)
|
411
411
|
end
|
412
|
+
|
413
|
+
it 'reports when element in shadow dom', requires: [:shadow_dom] do
|
414
|
+
@session.visit('/with_js')
|
415
|
+
shadow = @session.find(:css, '#shadow')
|
416
|
+
element = @session.evaluate_script(<<~JS, shadow)
|
417
|
+
(function(root){
|
418
|
+
return root.shadowRoot.querySelector('span');
|
419
|
+
})(arguments[0])
|
420
|
+
JS
|
421
|
+
expect(element.path).to eq '(: Shadow DOM element - no XPath :)'
|
422
|
+
end
|
412
423
|
end
|
413
424
|
|
414
425
|
describe '#trigger', requires: %i[js trigger] do
|
@@ -446,7 +457,7 @@ Capybara::SpecHelper.spec 'node' do
|
|
446
457
|
|
447
458
|
it 'should work with Dragula' do
|
448
459
|
@session.visit('/with_dragula')
|
449
|
-
@session.within(:css, '#sortable') do
|
460
|
+
@session.within(:css, '#sortable.ready') do
|
450
461
|
src = @session.find('div', text: 'Item 1')
|
451
462
|
target = @session.find('div', text: 'Item 3')
|
452
463
|
src.drag_to target
|
@@ -468,6 +479,50 @@ Capybara::SpecHelper.spec 'node' do
|
|
468
479
|
end
|
469
480
|
end
|
470
481
|
|
482
|
+
it 'should simulate a single held down modifier key' do
|
483
|
+
%I[
|
484
|
+
alt
|
485
|
+
ctrl
|
486
|
+
meta
|
487
|
+
shift
|
488
|
+
].each do |modifier_key|
|
489
|
+
@session.visit('/with_js')
|
490
|
+
|
491
|
+
element = @session.find('//div[@id="drag"]')
|
492
|
+
target = @session.find('//div[@id="drop"]')
|
493
|
+
|
494
|
+
element.drag_to(target, drop_modifiers: modifier_key)
|
495
|
+
expect(@session).to have_css('div.drag_start', exact_text: 'Dragged!')
|
496
|
+
expect(@session).to have_xpath("//div[contains(., 'Dropped!-#{modifier_key}')]")
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
it 'should simulate multiple held down modifier keys' do
|
501
|
+
@session.visit('/with_js')
|
502
|
+
|
503
|
+
element = @session.find('//div[@id="drag"]')
|
504
|
+
target = @session.find('//div[@id="drop"]')
|
505
|
+
|
506
|
+
modifier_keys = %I[alt ctrl meta shift]
|
507
|
+
|
508
|
+
element.drag_to(target, drop_modifiers: modifier_keys)
|
509
|
+
expect(@session).to have_xpath("//div[contains(., 'Dropped!-#{modifier_keys.join('-')}')]")
|
510
|
+
end
|
511
|
+
|
512
|
+
it 'should support key aliases' do
|
513
|
+
{ control: :ctrl,
|
514
|
+
command: :meta,
|
515
|
+
cmd: :meta }.each do |(key_alias, key)|
|
516
|
+
@session.visit('/with_js')
|
517
|
+
|
518
|
+
element = @session.find('//div[@id="drag"]')
|
519
|
+
target = @session.find('//div[@id="drop"]')
|
520
|
+
|
521
|
+
element.drag_to(target, drop_modifiers: [key_alias])
|
522
|
+
expect(target).to have_text("Dropped!-#{key}", exact: true)
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
471
526
|
context 'HTML5', requires: %i[js html5_drag] do
|
472
527
|
it 'should HTML5 drag and drop an object' do
|
473
528
|
@session.visit('/with_js')
|
@@ -493,6 +548,26 @@ Capybara::SpecHelper.spec 'node' do
|
|
493
548
|
expect(@session).to have_css('div.log', text: /DragOver with client position: [1-9]\d*,[1-9]\d*/, count: 2)
|
494
549
|
end
|
495
550
|
|
551
|
+
it 'should preserve clientX/Y from last dragover event' do
|
552
|
+
@session.visit('/with_js')
|
553
|
+
element = @session.find('//div[@id="drag_html5"]')
|
554
|
+
target = @session.find('//div[@id="drop_html5"]')
|
555
|
+
element.drag_to(target)
|
556
|
+
|
557
|
+
conditions = %w[DragLeave Drop DragEnd].map do |text|
|
558
|
+
have_css('div.log', text: text)
|
559
|
+
end
|
560
|
+
expect(@session).to(conditions.reduce { |memo, cond| memo.and(cond) })
|
561
|
+
|
562
|
+
# The first "DragOver" div is inserted by the last dragover event dispatched
|
563
|
+
drag_over_div = @session.first('//div[@class="log" and starts-with(text(), "DragOver")]')
|
564
|
+
position = drag_over_div.text.sub('DragOver ', '')
|
565
|
+
|
566
|
+
expect(@session).to have_css('div.log', text: /DragLeave #{position}/, count: 1)
|
567
|
+
expect(@session).to have_css('div.log', text: /Drop #{position}/, count: 1)
|
568
|
+
expect(@session).to have_css('div.log', text: /DragEnd #{position}/, count: 1)
|
569
|
+
end
|
570
|
+
|
496
571
|
it 'should not HTML5 drag and drop on a non HTML5 drop element' do
|
497
572
|
@session.visit('/with_js')
|
498
573
|
element = @session.find('//div[@id="drag_html5"]')
|
@@ -536,6 +611,46 @@ Capybara::SpecHelper.spec 'node' do
|
|
536
611
|
source.drag_to target
|
537
612
|
expect(@session).to have_xpath('//div[contains(., "HTML5 Dropped")]')
|
538
613
|
end
|
614
|
+
|
615
|
+
it 'should simulate a single held down modifier key' do
|
616
|
+
%I[alt ctrl meta shift].each do |modifier_key|
|
617
|
+
@session.visit('/with_js')
|
618
|
+
|
619
|
+
element = @session.find('//div[@id="drag_html5"]')
|
620
|
+
target = @session.find('//div[@id="drop_html5"]')
|
621
|
+
|
622
|
+
element.drag_to(target, drop_modifiers: modifier_key)
|
623
|
+
|
624
|
+
expect(@session).to have_css('div.drag_start', exact_text: 'HTML5 Dragged!')
|
625
|
+
expect(@session).to have_xpath("//div[contains(., 'HTML5 Dropped string: text/plain drag_html5-#{modifier_key}')]")
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
it 'should simulate multiple held down modifier keys' do
|
630
|
+
@session.visit('/with_js')
|
631
|
+
|
632
|
+
element = @session.find('//div[@id="drag_html5"]')
|
633
|
+
target = @session.find('//div[@id="drop_html5"]')
|
634
|
+
|
635
|
+
modifier_keys = %I[alt ctrl meta shift]
|
636
|
+
|
637
|
+
element.drag_to(target, drop_modifiers: modifier_keys)
|
638
|
+
expect(@session).to have_xpath("//div[contains(., 'HTML5 Dropped string: text/plain drag_html5-#{modifier_keys.join('-')}')]")
|
639
|
+
end
|
640
|
+
|
641
|
+
it 'should support key aliases' do
|
642
|
+
{ control: :ctrl,
|
643
|
+
command: :meta,
|
644
|
+
cmd: :meta }.each do |(key_alias, key)|
|
645
|
+
@session.visit('/with_js')
|
646
|
+
|
647
|
+
element = @session.find('//div[@id="drag_html5"]')
|
648
|
+
target = @session.find('//div[@id="drop_html5"]')
|
649
|
+
|
650
|
+
element.drag_to(target, drop_modifiers: [key_alias])
|
651
|
+
expect(target).to have_text(%r{^HTML5 Dropped string: text/plain drag_html5-#{key}$}m, exact: true)
|
652
|
+
end
|
653
|
+
end
|
539
654
|
end
|
540
655
|
end
|
541
656
|
|
@@ -567,6 +682,15 @@ Capybara::SpecHelper.spec 'node' do
|
|
567
682
|
expect(@session).to have_xpath('//div[contains(., "HTML5 Dropped string: text/plain Some dropped text")]')
|
568
683
|
end
|
569
684
|
|
685
|
+
it 'can drop a pathname' do
|
686
|
+
@session.visit('/with_js')
|
687
|
+
target = @session.find('//div[@id="drop_html5"]')
|
688
|
+
target.drop(
|
689
|
+
Pathname.new(with_os_path_separators(File.expand_path('../fixtures/capybara.jpg', File.dirname(__FILE__))))
|
690
|
+
)
|
691
|
+
expect(@session).to have_xpath('//div[contains(., "HTML5 Dropped file: capybara.jpg")]')
|
692
|
+
end
|
693
|
+
|
570
694
|
it 'can drop multiple strings' do
|
571
695
|
@session.visit('/with_js')
|
572
696
|
target = @session.find('//div[@id="drop_html5"]')
|
@@ -654,7 +778,7 @@ Capybara::SpecHelper.spec 'node' do
|
|
654
778
|
@session.visit('with_js')
|
655
779
|
@session.find(:css, '#click-test').click(x: 5, y: 5)
|
656
780
|
link = @session.find(:link, 'has-been-clicked')
|
657
|
-
locations = link.text.match(/^Has been clicked at (?<x>[\d
|
781
|
+
locations = link.text.match(/^Has been clicked at (?<x>[\d.-]+),(?<y>[\d.-]+)$/)
|
658
782
|
# Resulting click location should be very close to 0, 0 relative to top left corner of the element, but may not be exact due to
|
659
783
|
# integer/float conversions and rounding.
|
660
784
|
expect(locations[:x].to_f).to be_within(1).of(5)
|
@@ -704,7 +828,10 @@ Capybara::SpecHelper.spec 'node' do
|
|
704
828
|
context 'offset', requires: [:js] do
|
705
829
|
before do
|
706
830
|
@session.visit('/offset')
|
707
|
-
|
831
|
+
end
|
832
|
+
|
833
|
+
let :clicker do
|
834
|
+
@session.find(:id, 'clicker')
|
708
835
|
end
|
709
836
|
|
710
837
|
context 'when w3c_click_offset is false' do
|
@@ -713,17 +840,17 @@ Capybara::SpecHelper.spec 'node' do
|
|
713
840
|
end
|
714
841
|
|
715
842
|
it 'should offset from top left of element' do
|
716
|
-
|
843
|
+
clicker.click(x: 10, y: 5)
|
717
844
|
expect(@session).to have_text(/clicked at 110,105/)
|
718
845
|
end
|
719
846
|
|
720
847
|
it 'should offset outside the element' do
|
721
|
-
|
848
|
+
clicker.click(x: -15, y: -10)
|
722
849
|
expect(@session).to have_text(/clicked at 85,90/)
|
723
850
|
end
|
724
851
|
|
725
852
|
it 'should default to click the middle' do
|
726
|
-
|
853
|
+
clicker.click
|
727
854
|
expect(@session).to have_text(/clicked at 150,150/)
|
728
855
|
end
|
729
856
|
end
|
@@ -734,21 +861,30 @@ Capybara::SpecHelper.spec 'node' do
|
|
734
861
|
end
|
735
862
|
|
736
863
|
it 'should offset from center of element' do
|
737
|
-
|
864
|
+
clicker.click(x: 10, y: 5)
|
738
865
|
expect(@session).to have_text(/clicked at 160,155/)
|
739
866
|
end
|
740
867
|
|
741
868
|
it 'should offset outside from center of element' do
|
742
|
-
|
869
|
+
clicker.click(x: -65, y: -60)
|
743
870
|
expect(@session).to have_text(/clicked at 85,90/)
|
744
871
|
end
|
745
872
|
|
746
873
|
it 'should default to click the middle' do
|
747
|
-
|
874
|
+
clicker.click
|
748
875
|
expect(@session).to have_text(/clicked at 150,150/)
|
749
876
|
end
|
750
877
|
end
|
751
878
|
end
|
879
|
+
|
880
|
+
context 'delay', requires: [:js] do
|
881
|
+
it 'should delay the mouse up' do
|
882
|
+
@session.visit('with_js')
|
883
|
+
@session.find(:css, '#click-test').click(delay: 2)
|
884
|
+
delay = @session.evaluate_script('window.click_delay')
|
885
|
+
expect(delay).to be >= 2
|
886
|
+
end
|
887
|
+
end
|
752
888
|
end
|
753
889
|
|
754
890
|
describe '#double_click', requires: [:js] do
|
@@ -768,7 +904,7 @@ Capybara::SpecHelper.spec 'node' do
|
|
768
904
|
@session.visit('with_js')
|
769
905
|
@session.find(:css, '#click-test').double_click(x: 10, y: 5)
|
770
906
|
link = @session.find(:link, 'has-been-double-clicked')
|
771
|
-
locations = link.text.match(/^Has been double clicked at (?<x>[\d
|
907
|
+
locations = link.text.match(/^Has been double clicked at (?<x>[\d.-]+),(?<y>[\d.-]+)$/)
|
772
908
|
# Resulting click location should be very close to 10, 5 relative to top left corner of the element, but may not be exact due
|
773
909
|
# to integer/float conversions and rounding.
|
774
910
|
expect(locations[:x].to_f).to be_within(1).of(10)
|
@@ -787,7 +923,10 @@ Capybara::SpecHelper.spec 'node' do
|
|
787
923
|
context 'offset', requires: [:js] do
|
788
924
|
before do
|
789
925
|
@session.visit('/offset')
|
790
|
-
|
926
|
+
end
|
927
|
+
|
928
|
+
let :clicker do
|
929
|
+
@session.find(:id, 'clicker')
|
791
930
|
end
|
792
931
|
|
793
932
|
context 'when w3c_click_offset is false' do
|
@@ -796,17 +935,17 @@ Capybara::SpecHelper.spec 'node' do
|
|
796
935
|
end
|
797
936
|
|
798
937
|
it 'should offset from top left of element' do
|
799
|
-
|
938
|
+
clicker.double_click(x: 10, y: 5)
|
800
939
|
expect(@session).to have_text(/clicked at 110,105/)
|
801
940
|
end
|
802
941
|
|
803
942
|
it 'should offset outside the element' do
|
804
|
-
|
943
|
+
clicker.double_click(x: -15, y: -10)
|
805
944
|
expect(@session).to have_text(/clicked at 85,90/)
|
806
945
|
end
|
807
946
|
|
808
947
|
it 'should default to click the middle' do
|
809
|
-
|
948
|
+
clicker.double_click
|
810
949
|
expect(@session).to have_text(/clicked at 150,150/)
|
811
950
|
end
|
812
951
|
end
|
@@ -817,17 +956,17 @@ Capybara::SpecHelper.spec 'node' do
|
|
817
956
|
end
|
818
957
|
|
819
958
|
it 'should offset from center of element' do
|
820
|
-
|
959
|
+
clicker.double_click(x: 10, y: 5)
|
821
960
|
expect(@session).to have_text(/clicked at 160,155/)
|
822
961
|
end
|
823
962
|
|
824
963
|
it 'should offset outside from center of element' do
|
825
|
-
|
964
|
+
clicker.double_click(x: -65, y: -60)
|
826
965
|
expect(@session).to have_text(/clicked at 85,90/)
|
827
966
|
end
|
828
967
|
|
829
968
|
it 'should default to click the middle' do
|
830
|
-
|
969
|
+
clicker.double_click
|
831
970
|
expect(@session).to have_text(/clicked at 150,150/)
|
832
971
|
end
|
833
972
|
end
|
@@ -851,7 +990,7 @@ Capybara::SpecHelper.spec 'node' do
|
|
851
990
|
@session.visit('with_js')
|
852
991
|
@session.find(:css, '#click-test').right_click(x: 10, y: 10)
|
853
992
|
link = @session.find(:link, 'has-been-right-clicked')
|
854
|
-
locations = link.text.match(/^Has been right clicked at (?<x>[\d
|
993
|
+
locations = link.text.match(/^Has been right clicked at (?<x>[\d.-]+),(?<y>[\d.-]+)$/)
|
855
994
|
# Resulting click location should be very close to 10, 10 relative to top left corner of the element, but may not be exact due
|
856
995
|
# to integer/float conversions and rounding
|
857
996
|
expect(locations[:x].to_f).to be_within(1).of(10)
|
@@ -870,7 +1009,10 @@ Capybara::SpecHelper.spec 'node' do
|
|
870
1009
|
context 'offset', requires: [:js] do
|
871
1010
|
before do
|
872
1011
|
@session.visit('/offset')
|
873
|
-
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
let :clicker do
|
1015
|
+
@session.find(:id, 'clicker')
|
874
1016
|
end
|
875
1017
|
|
876
1018
|
context 'when w3c_click_offset is false' do
|
@@ -879,17 +1021,17 @@ Capybara::SpecHelper.spec 'node' do
|
|
879
1021
|
end
|
880
1022
|
|
881
1023
|
it 'should offset from top left of element' do
|
882
|
-
|
1024
|
+
clicker.right_click(x: 10, y: 5)
|
883
1025
|
expect(@session).to have_text(/clicked at 110,105/)
|
884
1026
|
end
|
885
1027
|
|
886
1028
|
it 'should offset outside the element' do
|
887
|
-
|
1029
|
+
clicker.right_click(x: -15, y: -10)
|
888
1030
|
expect(@session).to have_text(/clicked at 85,90/)
|
889
1031
|
end
|
890
1032
|
|
891
1033
|
it 'should default to click the middle' do
|
892
|
-
|
1034
|
+
clicker.right_click
|
893
1035
|
expect(@session).to have_text(/clicked at 150,150/)
|
894
1036
|
end
|
895
1037
|
end
|
@@ -900,21 +1042,30 @@ Capybara::SpecHelper.spec 'node' do
|
|
900
1042
|
end
|
901
1043
|
|
902
1044
|
it 'should offset from center of element' do
|
903
|
-
|
1045
|
+
clicker.right_click(x: 10, y: 5)
|
904
1046
|
expect(@session).to have_text(/clicked at 160,155/)
|
905
1047
|
end
|
906
1048
|
|
907
1049
|
it 'should offset outside from center of element' do
|
908
|
-
|
1050
|
+
clicker.right_click(x: -65, y: -60)
|
909
1051
|
expect(@session).to have_text(/clicked at 85,90/)
|
910
1052
|
end
|
911
1053
|
|
912
1054
|
it 'should default to click the middle' do
|
913
|
-
|
1055
|
+
clicker.right_click
|
914
1056
|
expect(@session).to have_text(/clicked at 150,150/)
|
915
1057
|
end
|
916
1058
|
end
|
917
1059
|
end
|
1060
|
+
|
1061
|
+
context 'delay', requires: [:js] do
|
1062
|
+
it 'should delay the mouse up' do
|
1063
|
+
@session.visit('with_js')
|
1064
|
+
@session.find(:css, '#click-test').right_click(delay: 2)
|
1065
|
+
delay = @session.evaluate_script('window.right_click_delay')
|
1066
|
+
expect(delay).to be >= 2
|
1067
|
+
end
|
1068
|
+
end
|
918
1069
|
end
|
919
1070
|
|
920
1071
|
describe '#send_keys', requires: [:send_keys] do
|
@@ -964,7 +1115,7 @@ Capybara::SpecHelper.spec 'node' do
|
|
964
1115
|
end
|
965
1116
|
|
966
1117
|
describe '#evaluate_script', requires: %i[js es_args] do
|
967
|
-
it 'should evaluate the given script in the context of the element and
|
1118
|
+
it 'should evaluate the given script in the context of the element and return whatever it produces' do
|
968
1119
|
@session.visit('/with_js')
|
969
1120
|
el = @session.find(:css, '#with_change_event')
|
970
1121
|
expect(el.evaluate_script('this.value')).to eq('default value')
|
@@ -1025,6 +1176,48 @@ Capybara::SpecHelper.spec 'node' do
|
|
1025
1176
|
end
|
1026
1177
|
end
|
1027
1178
|
|
1179
|
+
describe '#shadow_root', requires: %i[js] do
|
1180
|
+
it 'should get the shadow root' do
|
1181
|
+
@session.visit('/with_shadow')
|
1182
|
+
expect do
|
1183
|
+
shadow_root = @session.find(:css, '#shadow_host').shadow_root
|
1184
|
+
expect(shadow_root).not_to be_nil
|
1185
|
+
end.not_to raise_error
|
1186
|
+
end
|
1187
|
+
|
1188
|
+
it 'should find elements inside the shadow dom using CSS' do
|
1189
|
+
@session.visit('/with_shadow')
|
1190
|
+
shadow_root = @session.find(:css, '#shadow_host').shadow_root
|
1191
|
+
expect(shadow_root).to have_css('#shadow_content', text: 'some text')
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
it 'should find nested shadow roots' do
|
1195
|
+
@session.visit('/with_shadow')
|
1196
|
+
shadow_root = @session.find(:css, '#shadow_host').shadow_root
|
1197
|
+
nested_shadow_root = shadow_root.find(:css, '#nested_shadow_host').shadow_root
|
1198
|
+
expect(nested_shadow_root).to have_css('#nested_shadow_content', text: 'nested text')
|
1199
|
+
end
|
1200
|
+
|
1201
|
+
it 'should click on elements' do
|
1202
|
+
@session.visit('/with_shadow')
|
1203
|
+
shadow_root = @session.find(:css, '#shadow_host').shadow_root
|
1204
|
+
checkbox = shadow_root.find(:css, 'input[type="checkbox"]')
|
1205
|
+
expect(checkbox).not_to be_checked
|
1206
|
+
checkbox.click
|
1207
|
+
expect(checkbox).to be_checked
|
1208
|
+
end
|
1209
|
+
|
1210
|
+
it 'should use convenience methods once moved to a descendant of the shadow root' do
|
1211
|
+
@session.visit('/with_shadow')
|
1212
|
+
shadow_root = @session.find(:css, '#shadow_host').shadow_root
|
1213
|
+
descendant = shadow_root.find(:css, '#controls_wrapper')
|
1214
|
+
expect do
|
1215
|
+
descendant.check('shadow_checkbox')
|
1216
|
+
end.not_to raise_error
|
1217
|
+
expect(descendant).to have_checked_field('shadow_checkbox')
|
1218
|
+
end
|
1219
|
+
end
|
1220
|
+
|
1028
1221
|
describe '#reload', requires: [:js] do
|
1029
1222
|
it 'should reload elements found via ancestor with CSS' do
|
1030
1223
|
@session.visit('/with_js')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
|
4
4
|
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
|
5
5
|
# using Capybara provided assertions with builtin waiting behavior.
|
6
6
|
|
@@ -25,6 +25,7 @@ Capybara::SpecHelper.spec '#refresh' do
|
|
25
25
|
@session.visit('/form')
|
26
26
|
@session.select('Sweden', from: 'form_region')
|
27
27
|
@session.click_button('awesome')
|
28
|
+
sleep 2
|
28
29
|
expect do
|
29
30
|
@session.refresh
|
30
31
|
sleep 2
|
@@ -15,7 +15,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
|
|
15
15
|
@session.save_and_open_screenshot
|
16
16
|
|
17
17
|
expect(@session.driver).to have_received(:save_screenshot)
|
18
|
-
.with(expected_file_regex,
|
18
|
+
.with(expected_file_regex, any_args)
|
19
19
|
expect(Launchy).to have_received(:open).with(expected_file_regex)
|
20
20
|
end
|
21
21
|
|
@@ -27,7 +27,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
|
|
27
27
|
@session.save_and_open_screenshot(custom_path)
|
28
28
|
|
29
29
|
expect(@session.driver).to have_received(:save_screenshot)
|
30
|
-
.with(/#{custom_path}$/,
|
30
|
+
.with(/#{custom_path}$/, any_args)
|
31
31
|
expect(Launchy).to have_received(:open).with(/#{custom_path}$/)
|
32
32
|
end
|
33
33
|
|
@@ -31,7 +31,7 @@ Capybara::SpecHelper.spec '#save_page' do
|
|
31
31
|
it 'can store files in a specified directory' do
|
32
32
|
Capybara.save_path = alternative_path
|
33
33
|
@session.save_page
|
34
|
-
path = Dir.glob(alternative_path
|
34
|
+
path = Dir.glob("#{alternative_path}/capybara-*.html").first
|
35
35
|
expect(File.read(path)).to include('Another World')
|
36
36
|
end
|
37
37
|
|
@@ -43,14 +43,14 @@ Capybara::SpecHelper.spec '#save_page' do
|
|
43
43
|
it 'can store files in a specified directory with a given filename' do
|
44
44
|
Capybara.save_path = alternative_path
|
45
45
|
@session.save_page('capybara-001133.html')
|
46
|
-
path = alternative_path
|
46
|
+
path = "#{alternative_path}/capybara-001133.html"
|
47
47
|
expect(File.read(path)).to include('Another World')
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'can store files in a specified directory with a given relative filename' do
|
51
51
|
Capybara.save_path = alternative_path
|
52
52
|
@session.save_page('tmp/capybara-001144.html')
|
53
|
-
path = alternative_path
|
53
|
+
path = "#{alternative_path}/tmp/capybara-001144.html"
|
54
54
|
expect(File.read(path)).to include('Another World')
|
55
55
|
end
|
56
56
|
|
@@ -63,7 +63,7 @@ Capybara::SpecHelper.spec '#save_page' do
|
|
63
63
|
it 'returns an absolute path in given directory' do
|
64
64
|
Capybara.save_path = alternative_path
|
65
65
|
result = @session.save_page
|
66
|
-
path = File.expand_path(Dir.glob(alternative_path
|
66
|
+
path = File.expand_path(Dir.glob("#{alternative_path}/capybara-*.html").first, alternative_path)
|
67
67
|
expect(result).to eq(path)
|
68
68
|
end
|
69
69
|
|
@@ -19,7 +19,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
|
|
19
19
|
@session.save_screenshot
|
20
20
|
|
21
21
|
regexp = Regexp.new(File.join(Dir.pwd, 'capybara-\d+\.png'))
|
22
|
-
expect(@session.driver).to have_received(:save_screenshot).with(regexp,
|
22
|
+
expect(@session.driver).to have_received(:save_screenshot).with(regexp, any_args)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'allows to specify another path' do
|
@@ -28,7 +28,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
|
|
28
28
|
custom_path = 'screenshots/1.png'
|
29
29
|
@session.save_screenshot(custom_path)
|
30
30
|
|
31
|
-
expect(@session.driver).to have_received(:save_screenshot).with(/#{custom_path}$/,
|
31
|
+
expect(@session.driver).to have_received(:save_screenshot).with(/#{custom_path}$/, any_args)
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'with Capybara.save_path' do
|
@@ -39,7 +39,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
|
|
39
39
|
@session.save_screenshot
|
40
40
|
|
41
41
|
regexp = Regexp.new(File.join(alternative_path, 'capybara-\d+\.png'))
|
42
|
-
expect(@session.driver).to have_received(:save_screenshot).with(regexp,
|
42
|
+
expect(@session.driver).to have_received(:save_screenshot).with(regexp, any_args)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'relative paths are relative to save_path' do
|
@@ -49,7 +49,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
|
|
49
49
|
custom_path = 'screenshots/2.png'
|
50
50
|
@session.save_screenshot(custom_path)
|
51
51
|
|
52
|
-
expect(@session.driver).to have_received(:save_screenshot).with(File.expand_path(custom_path, alternative_path),
|
52
|
+
expect(@session.driver).to have_received(:save_screenshot).with(File.expand_path(custom_path, alternative_path), any_args)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -15,7 +15,7 @@ Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do
|
|
15
15
|
el = @session.find(:css, '#scroll')
|
16
16
|
@session.scroll_to(el, align: :bottom)
|
17
17
|
el_bottom = el.evaluate_script('this.getBoundingClientRect().bottom')
|
18
|
-
viewport_bottom = el.evaluate_script('document.
|
18
|
+
viewport_bottom = el.evaluate_script('document.documentElement.clientHeight')
|
19
19
|
expect(el_bottom).to be_within(1).of(viewport_bottom)
|
20
20
|
end
|
21
21
|
|
@@ -23,7 +23,7 @@ Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do
|
|
23
23
|
el = @session.find(:css, '#scroll')
|
24
24
|
@session.scroll_to(el, align: :center)
|
25
25
|
el_center = el.evaluate_script('(function(rect){return (rect.top + rect.bottom)/2})(this.getBoundingClientRect())')
|
26
|
-
viewport_bottom = el.evaluate_script('document.
|
26
|
+
viewport_bottom = el.evaluate_script('document.documentElement.clientHeight')
|
27
27
|
expect(el_center).to be_within(2).of(viewport_bottom / 2)
|
28
28
|
end
|
29
29
|
|
@@ -35,13 +35,13 @@ Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do
|
|
35
35
|
|
36
36
|
it 'can scroll the window to the vertical bottom' do
|
37
37
|
@session.scroll_to :bottom
|
38
|
-
max_scroll = @session.evaluate_script('document.
|
38
|
+
max_scroll = @session.evaluate_script('document.documentElement.scrollHeight - document.documentElement.clientHeight')
|
39
39
|
expect(@session.evaluate_script('[window.scrollX || window.pageXOffset, window.scrollY || window.pageYOffset]')).to eq [0, max_scroll]
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'can scroll the window to the vertical center' do
|
43
43
|
@session.scroll_to :center
|
44
|
-
max_scroll = @session.evaluate_script('document.documentElement.scrollHeight - document.
|
44
|
+
max_scroll = @session.evaluate_script('document.documentElement.scrollHeight - document.documentElement.clientHeight')
|
45
45
|
expect(@session.evaluate_script('[window.scrollX || window.pageXOffset, window.scrollY || window.pageYOffset]')).to eq [0, max_scroll / 2]
|
46
46
|
end
|
47
47
|
|
@@ -31,6 +31,11 @@ Capybara::SpecHelper.spec Capybara::Selector do
|
|
31
31
|
expect(@session.find(:label, for: input).text).to eq 'Nested Label'
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'finds a label from nested input using :for filter with element when no id on label' do
|
35
|
+
input = @session.find(:css, '#wrapper_label').find(:css, 'input')
|
36
|
+
expect(@session.find(:label, for: input).text).to eq 'Wrapper Label'
|
37
|
+
end
|
38
|
+
|
34
39
|
it 'finds the label for an non-nested element when using :for filter' do
|
35
40
|
select = @session.find(:id, 'form_other_title')
|
36
41
|
expect(@session.find(:label, for: select)['for']).to eq 'form_other_title'
|
@@ -62,14 +67,22 @@ Capybara::SpecHelper.spec Capybara::Selector do
|
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
65
|
-
it 'can find specifically by name' do
|
70
|
+
it 'can find specifically by name string' do
|
66
71
|
expect(@session.find(:field, name: 'form[other_title]')['id']).to eq 'form_other_title'
|
67
72
|
end
|
68
73
|
|
69
|
-
it 'can find specifically by
|
74
|
+
it 'can find specifically by name regex' do
|
75
|
+
expect(@session.find(:field, name: /form\[other_.*\]/)['id']).to eq 'form_other_title'
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'can find specifically by placeholder string' do
|
70
79
|
expect(@session.find(:field, placeholder: 'FirstName')['id']).to eq 'form_first_name'
|
71
80
|
end
|
72
81
|
|
82
|
+
it 'can find specifically by placeholder regex' do
|
83
|
+
expect(@session.find(:field, placeholder: /FirstN.*/)['id']).to eq 'form_first_name'
|
84
|
+
end
|
85
|
+
|
73
86
|
it 'can find by type' do
|
74
87
|
expect(@session.find(:field, 'Confusion', type: 'checkbox')['id']).to eq 'confusion_checkbox'
|
75
88
|
expect(@session.find(:field, 'Confusion', type: 'text')['id']).to eq 'confusion_text'
|
@@ -201,4 +201,24 @@ Capybara::SpecHelper.spec '#visit' do
|
|
201
201
|
@session.visit('/get_cookie')
|
202
202
|
expect(@session).to have_content('root cookie')
|
203
203
|
end
|
204
|
+
|
205
|
+
context 'with base element' do
|
206
|
+
it 'should use base href with relative links' do
|
207
|
+
@session.visit('/base/with_base')
|
208
|
+
@session.click_link('Title page')
|
209
|
+
expect(@session).to have_current_path('/with_title')
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'should use base href with bare queries' do
|
213
|
+
@session.visit('/base/with_base')
|
214
|
+
@session.click_link('Bare query')
|
215
|
+
expect(@session).to have_current_path('/?a=3')
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should not use the base href with a new visit call' do
|
219
|
+
@session.visit('/base/with_other_base')
|
220
|
+
@session.visit('with_html')
|
221
|
+
expect(@session).to have_current_path('/with_html')
|
222
|
+
end
|
223
|
+
end
|
204
224
|
end
|