capybara 3.35.3 → 3.37.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 +57 -1
- data/README.md +5 -1
- data/lib/capybara/config.rb +16 -4
- data/lib/capybara/driver/base.rb +4 -0
- data/lib/capybara/driver/node.rb +5 -1
- data/lib/capybara/dsl.rb +4 -10
- data/lib/capybara/helpers.rb +3 -12
- data/lib/capybara/minitest/spec.rb +2 -2
- data/lib/capybara/node/actions.rb +10 -5
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/element.rb +13 -2
- data/lib/capybara/node/finders.rb +9 -2
- data/lib/capybara/node/simple.rb +5 -1
- data/lib/capybara/queries/active_element_query.rb +18 -0
- data/lib/capybara/queries/ancestor_query.rb +2 -1
- data/lib/capybara/queries/current_path_query.rb +1 -1
- data/lib/capybara/queries/selector_query.rb +34 -8
- data/lib/capybara/queries/sibling_query.rb +2 -1
- data/lib/capybara/rack_test/browser.rb +56 -7
- data/lib/capybara/rack_test/driver.rb +4 -4
- data/lib/capybara/rack_test/node.rb +10 -7
- data/lib/capybara/registration_container.rb +0 -3
- data/lib/capybara/registrations/drivers.rb +3 -3
- data/lib/capybara/rspec/matcher_proxies.rb +3 -3
- data/lib/capybara/rspec/matchers/have_selector.rb +5 -5
- data/lib/capybara/rspec/matchers.rb +14 -14
- data/lib/capybara/selector/builders/css_builder.rb +1 -1
- data/lib/capybara/selector/builders/xpath_builder.rb +1 -1
- data/lib/capybara/selector/css.rb +1 -1
- data/lib/capybara/selector/definition/button.rb +9 -4
- data/lib/capybara/selector/definition/checkbox.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/radio_button.rb +1 -1
- data/lib/capybara/selector/definition.rb +3 -1
- data/lib/capybara/selector/filter_set.rb +4 -6
- data/lib/capybara/selector/selector.rb +5 -1
- data/lib/capybara/selector.rb +1 -0
- data/lib/capybara/selenium/driver.rb +25 -11
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +1 -1
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +1 -1
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +1 -1
- data/lib/capybara/selenium/node.rb +22 -8
- data/lib/capybara/selenium/nodes/chrome_node.rb +1 -1
- data/lib/capybara/selenium/nodes/edge_node.rb +1 -1
- data/lib/capybara/selenium/nodes/firefox_node.rb +1 -1
- data/lib/capybara/selenium/nodes/safari_node.rb +2 -2
- data/lib/capybara/server/animation_disabler.rb +35 -17
- data/lib/capybara/session/config.rb +1 -1
- data/lib/capybara/session.rb +20 -23
- data/lib/capybara/spec/session/active_element_spec.rb +31 -0
- data/lib/capybara/spec/session/all_spec.rb +9 -13
- data/lib/capybara/spec/session/assert_text_spec.rb +17 -17
- data/lib/capybara/spec/session/check_spec.rb +9 -0
- data/lib/capybara/spec/session/choose_spec.rb +6 -0
- data/lib/capybara/spec/session/find_spec.rb +6 -0
- data/lib/capybara/spec/session/has_any_selectors_spec.rb +4 -0
- data/lib/capybara/spec/session/has_button_spec.rb +24 -0
- data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
- data/lib/capybara/spec/session/has_field_spec.rb +25 -1
- data/lib/capybara/spec/session/has_link_spec.rb +30 -0
- data/lib/capybara/spec/session/has_select_spec.rb +4 -4
- data/lib/capybara/spec/session/has_selector_spec.rb +15 -0
- data/lib/capybara/spec/session/has_text_spec.rb +2 -6
- data/lib/capybara/spec/session/node_spec.rb +43 -1
- data/lib/capybara/spec/session/scroll_spec.rb +4 -4
- data/lib/capybara/spec/session/visit_spec.rb +20 -0
- data/lib/capybara/spec/session/window/window_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +4 -3
- data/lib/capybara/spec/test_app.rb +66 -8
- data/lib/capybara/spec/views/animated.erb +1 -1
- data/lib/capybara/spec/views/form.erb +11 -3
- 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 +2 -3
- data/lib/capybara/spec/views/with_base_tag.erb +2 -2
- data/lib/capybara/spec/views/with_dragula.erb +2 -2
- 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 +1 -1
- data/lib/capybara/spec/views/with_jquery_animation.erb +1 -1
- data/lib/capybara/spec/views/with_js.erb +2 -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 +2 -2
- 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 +1 -1
- data/lib/capybara.rb +19 -22
- data/spec/basic_node_spec.rb +16 -3
- data/spec/dsl_spec.rb +3 -3
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
- data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
- data/spec/rack_test_spec.rb +20 -10
- data/spec/result_spec.rb +32 -35
- data/spec/rspec/features_spec.rb +3 -3
- data/spec/rspec/scenarios_spec.rb +1 -1
- data/spec/rspec/shared_spec_matchers.rb +2 -2
- data/spec/sauce_spec_chrome.rb +3 -3
- data/spec/selector_spec.rb +2 -2
- data/spec/selenium_spec_chrome.rb +9 -10
- data/spec/selenium_spec_chrome_remote.rb +9 -8
- data/spec/selenium_spec_firefox.rb +8 -3
- 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 +5 -5
- data/spec/shared_selenium_node.rb +0 -4
- data/spec/shared_selenium_session.rb +20 -10
- data/spec/spec_helper.rb +1 -1
- metadata +37 -14
- data/lib/capybara/spec/views/with_title.erb +0 -5
|
@@ -15,6 +15,7 @@ browser_options.profile = Selenium::WebDriver::Firefox::Profile.new.tap do |prof
|
|
|
15
15
|
profile['browser.download.folderList'] = 2
|
|
16
16
|
profile['browser.helperApps.neverAsk.saveToDisk'] = 'text/csv'
|
|
17
17
|
profile['browser.startup.homepage'] = 'about:blank' # workaround bug in Selenium 4 alpha4-7
|
|
18
|
+
profile['accessibility.tabfocus'] = 7 # make tab move over links too
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
Capybara.register_driver :selenium_firefox do |app|
|
|
@@ -59,8 +60,8 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capyba
|
|
|
59
60
|
when 'Capybara::Session selenium #attach_file with multipart form should fire change once when uploading multiple files from empty'
|
|
60
61
|
pending "FF < 62 doesn't support setting all files at once" if firefox_lt?(62, @session)
|
|
61
62
|
when 'Capybara::Session selenium #accept_confirm should work with nested modals'
|
|
62
|
-
skip 'Broken in 63 <= FF < 69
|
|
63
|
-
skip 'Hangs in 69 <= FF < 71
|
|
63
|
+
skip 'Broken in 63 <= FF < 69 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if firefox_gte?(63, @session) && firefox_lt?(69, @session)
|
|
64
|
+
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)
|
|
64
65
|
skip 'Broken again intermittently in FF 71 - jus skip it'
|
|
65
66
|
when 'Capybara::Session selenium #click_link can download a file'
|
|
66
67
|
skip 'Need to figure out testing of file downloading on windows platform' if Gem.win_platform?
|
|
@@ -71,6 +72,10 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capyba
|
|
|
71
72
|
when 'Capybara::Session selenium #accept_alert should handle the alert if the page changes',
|
|
72
73
|
'Capybara::Session selenium #accept_alert with an asynchronous alert should accept the alert'
|
|
73
74
|
skip 'No clue what Firefox is doing here - works fine on MacOS locally'
|
|
75
|
+
when 'Capybara::Session selenium node #shadow_root should get the shadow root',
|
|
76
|
+
'Capybara::Session selenium node #shadow_root should find elements inside the shadow dom using CSS',
|
|
77
|
+
'Capybara::Session selenium node #shadow_root should find nested shadow roots'
|
|
78
|
+
pending "Firefox doesn't yet have W3C shadow root support"
|
|
74
79
|
end
|
|
75
80
|
end
|
|
76
81
|
|
|
@@ -102,7 +107,7 @@ RSpec.describe 'Capybara::Session with firefox' do # rubocop:disable RSpec/Multi
|
|
|
102
107
|
end
|
|
103
108
|
|
|
104
109
|
it 'should fill in a datetime input with a String' do
|
|
105
|
-
|
|
110
|
+
pending 'Need to figure out what string format this will actually accept'
|
|
106
111
|
session.fill_in('form_datetime', with: datetime.iso8601)
|
|
107
112
|
session.click_button('awesome')
|
|
108
113
|
expect(Time.parse(extract_results(session)['datetime'])).to eq datetime
|
|
@@ -21,8 +21,8 @@ def ensure_selenium_running!
|
|
|
21
21
|
rescue StandardError
|
|
22
22
|
if timer.expired?
|
|
23
23
|
raise 'Selenium is not running. ' \
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
"You can run a selenium server easily with: \n" \
|
|
25
|
+
' $ docker-compose up -d selenium_firefox'
|
|
26
26
|
else
|
|
27
27
|
puts 'Waiting for Selenium docker instance...'
|
|
28
28
|
sleep 1
|
data/spec/selenium_spec_ie.rb
CHANGED
|
@@ -71,13 +71,10 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_sk
|
|
|
71
71
|
pending "IE 11 doesn't support date input types"
|
|
72
72
|
when /#click_link_or_button with :disabled option happily clicks on links which incorrectly have the disabled attribute$/
|
|
73
73
|
skip 'IE 11 obeys non-standard disabled attribute on anchor tag'
|
|
74
|
-
when /#
|
|
75
|
-
skip "Windows can't :meta click because :meta triggers start menu"
|
|
76
|
-
when /#click should allow modifiers$/
|
|
74
|
+
when /#click should allow modifiers$/, /#double_click should allow modifiers$/
|
|
77
75
|
pending "Doesn't work with IE for some unknown reason$"
|
|
78
|
-
when /#double_click should allow modifiers$/
|
|
79
76
|
pending "Doesn't work with IE for some unknown reason$"
|
|
80
|
-
when /#click should allow multiple modifiers$/
|
|
77
|
+
when /#click should allow multiple modifiers$/, /#right_click should allow modifiers$/
|
|
81
78
|
skip "Windows can't :meta click because :meta triggers start menu"
|
|
82
79
|
when /#double_click should allow multiple modifiers$/
|
|
83
80
|
skip "Windows can't :alt double click due to being properties shortcut"
|
|
@@ -91,7 +88,7 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_sk
|
|
|
91
88
|
pending "Window 7 and 8.1 don't support 308 http status code"
|
|
92
89
|
when /#scroll_to can scroll an element to the center of the viewport$/,
|
|
93
90
|
/#scroll_to can scroll an element to the center of the scrolling element$/
|
|
94
|
-
pending "
|
|
91
|
+
pending "IE doesn't support ScrollToOptions"
|
|
95
92
|
when /#attach_file with multipart form should fire change once for each set of files uploaded$/,
|
|
96
93
|
/#attach_file with multipart form should fire change once when uploading multiple files from empty$/,
|
|
97
94
|
/#attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files$/
|
|
@@ -8,28 +8,40 @@ require 'rspec/shared_spec_matchers'
|
|
|
8
8
|
|
|
9
9
|
SAFARI_DRIVER = :selenium_safari
|
|
10
10
|
|
|
11
|
-
if ::Selenium::WebDriver::Service.respond_to? :driver_path=
|
|
12
|
-
|
|
13
|
-
else
|
|
14
|
-
|
|
15
|
-
end.driver_path = '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
|
|
11
|
+
# if ::Selenium::WebDriver::Service.respond_to? :driver_path=
|
|
12
|
+
# ::Selenium::WebDriver::Safari::Service
|
|
13
|
+
# else
|
|
14
|
+
# ::Selenium::WebDriver::Safari
|
|
15
|
+
# end.driver_path = '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
|
|
16
16
|
|
|
17
17
|
browser_options = ::Selenium::WebDriver::Safari::Options.new
|
|
18
18
|
# browser_options.headless! if ENV['HEADLESS']
|
|
19
|
-
# browser_options.add_option(:w3c, !!ENV['W3C'])
|
|
20
19
|
|
|
21
20
|
Capybara.register_driver :selenium_safari do |app|
|
|
22
|
-
Capybara::Selenium::Driver.
|
|
21
|
+
version = Capybara::Selenium::Driver.load_selenium
|
|
22
|
+
options_key = Capybara::Selenium::Driver::CAPS_VERSION.satisfied_by?(version) ? :capabilities : :options
|
|
23
|
+
driver_options = { browser: :safari, timeout: 30 }.tap do |opts|
|
|
24
|
+
opts[options_key] = browser_options
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Capybara::Selenium::Driver.new(app, **driver_options).tap do |driver|
|
|
23
28
|
# driver.browser.download_path = Capybara.save_path
|
|
24
29
|
end
|
|
25
30
|
end
|
|
26
31
|
|
|
27
32
|
Capybara.register_driver :selenium_safari_not_clear_storage do |app|
|
|
28
|
-
|
|
33
|
+
version = Capybara::Selenium::Driver.load_selenium
|
|
34
|
+
options_key = Capybara::Selenium::Driver::CAPS_VERSION.satisfied_by?(version) ? :capabilities : :options
|
|
35
|
+
driver_options = {
|
|
29
36
|
browser: :safari,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
clear_local_storage: false,
|
|
38
|
+
clear_session_storage: false,
|
|
39
|
+
timeout: 30
|
|
40
|
+
}.tap do |opts|
|
|
41
|
+
opts[options_key] = browser_options
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Capybara::Selenium::Driver.new(app, **driver_options)
|
|
33
45
|
end
|
|
34
46
|
|
|
35
47
|
module TestSessions
|
|
@@ -65,16 +77,17 @@ Capybara::SpecHelper.run_specs TestSessions::Safari, SAFARI_DRIVER.to_s, capybar
|
|
|
65
77
|
when 'Capybara::Session selenium_safari node #double_click should allow to adjust the offset',
|
|
66
78
|
'Capybara::Session selenium_safari node #double_click should double click an element'
|
|
67
79
|
pending "safardriver doesn't generate a double click event"
|
|
68
|
-
when 'Capybara::Session selenium_safari node #
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
pending "safardriver clear doesn't generate change event"
|
|
80
|
+
when 'Capybara::Session selenium_safari node #double_click should allow modifiers'
|
|
81
|
+
pending "safaridriver doesn't generate double click with key modifiers"
|
|
82
|
+
when /when w3c_click_offset is true should offset/
|
|
83
|
+
pending 'w3c_click_offset is not currently supported with safaridriver'
|
|
73
84
|
when 'Capybara::Session selenium_safari #go_back should fetch a response from the driver from the previous page',
|
|
74
85
|
'Capybara::Session selenium_safari #go_forward should fetch a response from the driver from the previous page'
|
|
75
86
|
skip 'safaridriver loses the ability to find elements in the document after `go_back`'
|
|
76
|
-
when
|
|
77
|
-
|
|
87
|
+
when 'Capybara::Session selenium node #shadow_root should get the shadow root',
|
|
88
|
+
'Capybara::Session selenium node #shadow_root should find elements inside the shadow dom using CSS',
|
|
89
|
+
'Capybara::Session selenium node #shadow_root should find nested shadow roots'
|
|
90
|
+
pending "Safari doesn't yet have W3C shadow root support"
|
|
78
91
|
end
|
|
79
92
|
end
|
|
80
93
|
|
|
@@ -124,7 +137,6 @@ RSpec.describe 'Capybara::Session with safari' do
|
|
|
124
137
|
end
|
|
125
138
|
|
|
126
139
|
it 'should fill in a date input with a String' do
|
|
127
|
-
pending "Safari doesn't support date inputs"
|
|
128
140
|
session.fill_in('form_date', with: '06/19/1983')
|
|
129
141
|
session.click_button('awesome')
|
|
130
142
|
expect(Date.parse(extract_results(session)['date'])).to eq datetime.to_date
|
data/spec/server_spec.rb
CHANGED
|
@@ -20,7 +20,7 @@ RSpec.describe Capybara::Server do
|
|
|
20
20
|
|
|
21
21
|
it 'should bind to the specified host' do
|
|
22
22
|
# TODO: travis with jruby in container mode has an issue with this test
|
|
23
|
-
skip 'This platform has an issue with this test' if (ENV
|
|
23
|
+
skip 'This platform has an issue with this test' if (ENV.fetch('TRAVIS', nil) && (RUBY_ENGINE == 'jruby')) || Gem.win_platform?
|
|
24
24
|
|
|
25
25
|
begin
|
|
26
26
|
app = proc { |_env| [200, {}, ['Hello Server!']] }
|
|
@@ -78,7 +78,7 @@ RSpec.describe Capybara::Server do
|
|
|
78
78
|
# Use a port to force a EADDRINUSE error to be generated
|
|
79
79
|
server = TCPServer.new('0.0.0.0', 0)
|
|
80
80
|
server_port = server.addr[1]
|
|
81
|
-
d_server = instance_double(
|
|
81
|
+
d_server = instance_double(TCPServer, addr: [nil, server_port, nil, nil], close: nil)
|
|
82
82
|
call_count = 0
|
|
83
83
|
allow(TCPServer).to receive(:new).and_wrap_original do |m, *args|
|
|
84
84
|
call_count.zero? ? d_server : m.call(*args)
|
|
@@ -184,7 +184,7 @@ RSpec.describe Capybara::Server do
|
|
|
184
184
|
start_request(server2, 3.0)
|
|
185
185
|
server1.wait_for_pending_requests
|
|
186
186
|
end.to change { done }.from(0).to(2)
|
|
187
|
-
expect(server2.send(:pending_requests?)).to
|
|
187
|
+
expect(server2.send(:pending_requests?)).to be(false)
|
|
188
188
|
end
|
|
189
189
|
end
|
|
190
190
|
|
|
@@ -229,7 +229,7 @@ RSpec.describe Capybara::Server do
|
|
|
229
229
|
start_request(server2, 3.0)
|
|
230
230
|
server1.wait_for_pending_requests
|
|
231
231
|
end.to change { done }.from(0).to(1)
|
|
232
|
-
expect(server2.send(:pending_requests?)).to
|
|
232
|
+
expect(server2.send(:pending_requests?)).to be(true)
|
|
233
233
|
expect do
|
|
234
234
|
server2.wait_for_pending_requests
|
|
235
235
|
end.to change { done }.from(1).to(2)
|
|
@@ -274,7 +274,7 @@ RSpec.describe Capybara::Server do
|
|
|
274
274
|
app = -> { [200, {}, ['Hello, world']] }
|
|
275
275
|
server = described_class.new(app)
|
|
276
276
|
allow(Net::HTTP).to receive(:start).and_raise(SystemCallError.allocate)
|
|
277
|
-
expect(server.responsive?).to
|
|
277
|
+
expect(server.responsive?).to be false
|
|
278
278
|
end
|
|
279
279
|
|
|
280
280
|
[EOFError, Net::ReadTimeout].each do |err|
|
|
@@ -61,8 +61,6 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it 'will use native displayed if told to' do
|
|
64
|
-
pending "Chromedriver < 76.0.3809.25 doesn't support native displayed in W3C mode" if chrome_lt?(76, session) && (ENV['W3C'] != 'false')
|
|
65
|
-
|
|
66
64
|
session.driver.options[:native_displayed] = true
|
|
67
65
|
session.visit('/form')
|
|
68
66
|
session.find(:css, '#address1_city', visible: true)
|
|
@@ -71,8 +69,6 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
|
|
71
69
|
end
|
|
72
70
|
|
|
73
71
|
it "won't use native displayed if told not to" do
|
|
74
|
-
skip 'Non-W3C uses native' if chrome?(session) && (ENV['W3C'] == 'false')
|
|
75
|
-
|
|
76
72
|
session.driver.options[:native_displayed] = false
|
|
77
73
|
session.visit('/form')
|
|
78
74
|
session.find(:css, '#address1_city', visible: true)
|
|
@@ -23,7 +23,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
23
23
|
it 'freshly reset session should not be touched' do
|
|
24
24
|
session.instance_variable_set(:@touched, true)
|
|
25
25
|
session.reset!
|
|
26
|
-
expect(session.instance_variable_get(:@touched)).to
|
|
26
|
+
expect(session.instance_variable_get(:@touched)).to be false
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -74,7 +74,6 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
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
|
-
pending "safaridriver doesn't trigger change for clear" if safari?(session)
|
|
78
77
|
session.visit('/with_js')
|
|
79
78
|
session.fill_in('with_change_event', with: '')
|
|
80
79
|
# click outside the field to trigger the change event
|
|
@@ -188,14 +187,12 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
188
187
|
|
|
189
188
|
it 'should generate standard events on changing value' do
|
|
190
189
|
pending "IE 11 doesn't support date input type" if ie?(session)
|
|
191
|
-
pending "Safari doesn't support date input type" if safari?(session)
|
|
192
190
|
session.fill_in('form_date', with: Date.today)
|
|
193
191
|
expect(session.evaluate_script('window.capybara_formDateFiredEvents')).to eq %w[focus input change]
|
|
194
192
|
end
|
|
195
193
|
|
|
196
194
|
it 'should not generate input and change events if the value is not changed' do
|
|
197
195
|
pending "IE 11 doesn't support date input type" if ie?(session)
|
|
198
|
-
pending "Safari doesn't support date input type" if safari?(session)
|
|
199
196
|
session.fill_in('form_date', with: Date.today)
|
|
200
197
|
session.fill_in('form_date', with: Date.today)
|
|
201
198
|
# Chrome adds an extra focus for some reason - ok for now
|
|
@@ -223,14 +220,14 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
223
220
|
end
|
|
224
221
|
|
|
225
222
|
describe '#send_keys' do
|
|
226
|
-
it 'defaults to sending keys to the
|
|
223
|
+
it 'defaults to sending keys to the active_element' do
|
|
227
224
|
session.visit('/form')
|
|
228
225
|
|
|
229
|
-
expect(session.
|
|
226
|
+
expect(session.active_element).to match_selector(:css, 'body')
|
|
230
227
|
|
|
231
228
|
session.send_keys(:tab)
|
|
232
229
|
|
|
233
|
-
expect(session.
|
|
230
|
+
expect(session.active_element).to match_selector(:css, '[tabindex="1"]')
|
|
234
231
|
end
|
|
235
232
|
end
|
|
236
233
|
|
|
@@ -283,6 +280,13 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
283
280
|
expect(element).to eq session.find(:id, 'form_title')
|
|
284
281
|
end
|
|
285
282
|
|
|
283
|
+
it 'returns a shadow root' do
|
|
284
|
+
session.visit('/with_shadow')
|
|
285
|
+
shadow = session.find(:css, '#shadow_host')
|
|
286
|
+
element = session.evaluate_script('arguments[0].shadowRoot', shadow)
|
|
287
|
+
expect(element).to be_instance_of(Capybara::Node::Element)
|
|
288
|
+
end
|
|
289
|
+
|
|
286
290
|
it 'can return arrays of nested elements' do
|
|
287
291
|
session.visit('/form')
|
|
288
292
|
elements = session.evaluate_script('document.querySelectorAll("#form_city option")')
|
|
@@ -339,7 +343,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
339
343
|
it 'can attach a directory' do
|
|
340
344
|
pending "Geckodriver doesn't support uploading a directory" if firefox?(session)
|
|
341
345
|
pending "Selenium remote doesn't support transferring a directory" if remote?(session)
|
|
342
|
-
pending "Headless Chrome doesn't support directory upload - https://bugs.chromium.org/p/chromedriver/issues/detail?id=2521&q=directory%20upload&colspec=ID%20Status%20Pri%20Owner%20Summary" if chrome?(session) && ENV
|
|
346
|
+
pending "Headless Chrome doesn't support directory upload - https://bugs.chromium.org/p/chromedriver/issues/detail?id=2521&q=directory%20upload&colspec=ID%20Status%20Pri%20Owner%20Summary" if chrome?(session) && ENV.fetch('HEADLESS', nil)
|
|
343
347
|
pending "IE doesn't support uploading a directory" if ie?(session)
|
|
344
348
|
pending 'Chrome/chromedriver 73 breaks this' if chrome?(session) && chrome_gte?(73, session) && chrome_lt?(75, session)
|
|
345
349
|
pending "Safari doesn't support uploading a directory" if safari?(session)
|
|
@@ -381,6 +385,12 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
381
385
|
@animation_session = Capybara::Session.new(session.mode, TestApp.new)
|
|
382
386
|
end
|
|
383
387
|
|
|
388
|
+
it 'should add CSS to the <head> element' do
|
|
389
|
+
@animation_session.visit('with_animation')
|
|
390
|
+
|
|
391
|
+
expect(@animation_session).to have_selector(:css, 'head > style', text: 'transition: none', visible: :hidden)
|
|
392
|
+
end
|
|
393
|
+
|
|
384
394
|
it 'should disable CSS transitions' do
|
|
385
395
|
@animation_session.visit('with_animation')
|
|
386
396
|
@animation_session.click_link('transition me away')
|
|
@@ -514,8 +524,8 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
514
524
|
|
|
515
525
|
it 'can query attributes with strange characters' do
|
|
516
526
|
session.visit('/form')
|
|
517
|
-
expect(session).to have_selector(:element,
|
|
518
|
-
expect(session).to have_selector(:element,
|
|
527
|
+
expect(session).to have_selector(:element, '{custom}': true)
|
|
528
|
+
expect(session).to have_selector(:element, '{custom}': 'abcdef')
|
|
519
529
|
end
|
|
520
530
|
end
|
|
521
531
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'rspec/expectations'
|
|
4
|
-
require 'webdrivers' if ENV
|
|
4
|
+
require 'webdrivers' if ENV.fetch('CI', nil) || ENV.fetch('WEBDRIVERS', nil)
|
|
5
5
|
require 'selenium_statistics'
|
|
6
6
|
if ENV['TRAVIS']
|
|
7
7
|
require 'coveralls'
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capybara
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.37.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Walpole
|
|
8
8
|
- Jonas Nicklas
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
|
-
cert_chain:
|
|
12
|
-
-
|
|
13
|
-
date: 2021-01-30 00:00:00.000000000 Z
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: addressable
|
|
@@ -26,6 +25,20 @@ dependencies:
|
|
|
26
25
|
- - ">="
|
|
27
26
|
- !ruby/object:Gem::Version
|
|
28
27
|
version: '0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: matrix
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
29
42
|
- !ruby/object:Gem::Dependency
|
|
30
43
|
name: mini_mime
|
|
31
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -372,16 +385,22 @@ dependencies:
|
|
|
372
385
|
name: selenium-webdriver
|
|
373
386
|
requirement: !ruby/object:Gem::Requirement
|
|
374
387
|
requirements:
|
|
375
|
-
- - "
|
|
388
|
+
- - ">="
|
|
389
|
+
- !ruby/object:Gem::Version
|
|
390
|
+
version: 3.142.7
|
|
391
|
+
- - "<"
|
|
376
392
|
- !ruby/object:Gem::Version
|
|
377
|
-
version: '
|
|
393
|
+
version: '5.0'
|
|
378
394
|
type: :development
|
|
379
395
|
prerelease: false
|
|
380
396
|
version_requirements: !ruby/object:Gem::Requirement
|
|
381
397
|
requirements:
|
|
382
|
-
- - "
|
|
398
|
+
- - ">="
|
|
399
|
+
- !ruby/object:Gem::Version
|
|
400
|
+
version: 3.142.7
|
|
401
|
+
- - "<"
|
|
383
402
|
- !ruby/object:Gem::Version
|
|
384
|
-
version: '
|
|
403
|
+
version: '5.0'
|
|
385
404
|
- !ruby/object:Gem::Dependency
|
|
386
405
|
name: sinatra
|
|
387
406
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -468,6 +487,7 @@ files:
|
|
|
468
487
|
- lib/capybara/node/finders.rb
|
|
469
488
|
- lib/capybara/node/matchers.rb
|
|
470
489
|
- lib/capybara/node/simple.rb
|
|
490
|
+
- lib/capybara/queries/active_element_query.rb
|
|
471
491
|
- lib/capybara/queries/ancestor_query.rb
|
|
472
492
|
- lib/capybara/queries/base_query.rb
|
|
473
493
|
- lib/capybara/queries/current_path_query.rb
|
|
@@ -587,6 +607,7 @@ files:
|
|
|
587
607
|
- lib/capybara/spec/session/accept_alert_spec.rb
|
|
588
608
|
- lib/capybara/spec/session/accept_confirm_spec.rb
|
|
589
609
|
- lib/capybara/spec/session/accept_prompt_spec.rb
|
|
610
|
+
- lib/capybara/spec/session/active_element_spec.rb
|
|
590
611
|
- lib/capybara/spec/session/all_spec.rb
|
|
591
612
|
- lib/capybara/spec/session/ancestor_spec.rb
|
|
592
613
|
- lib/capybara/spec/session/assert_all_of_selectors_spec.rb
|
|
@@ -686,6 +707,7 @@ files:
|
|
|
686
707
|
- lib/capybara/spec/views/header_links.erb
|
|
687
708
|
- lib/capybara/spec/views/host_links.erb
|
|
688
709
|
- lib/capybara/spec/views/initial_alert.erb
|
|
710
|
+
- lib/capybara/spec/views/layout.erb
|
|
689
711
|
- lib/capybara/spec/views/obscured.erb
|
|
690
712
|
- lib/capybara/spec/views/offset.erb
|
|
691
713
|
- lib/capybara/spec/views/path.erb
|
|
@@ -712,10 +734,10 @@ files:
|
|
|
712
734
|
- lib/capybara/spec/views/with_namespace.erb
|
|
713
735
|
- lib/capybara/spec/views/with_scope.erb
|
|
714
736
|
- lib/capybara/spec/views/with_scope_other.erb
|
|
737
|
+
- lib/capybara/spec/views/with_shadow.erb
|
|
715
738
|
- lib/capybara/spec/views/with_simple_html.erb
|
|
716
739
|
- lib/capybara/spec/views/with_slow_unload.erb
|
|
717
740
|
- lib/capybara/spec/views/with_sortable_js.erb
|
|
718
|
-
- lib/capybara/spec/views/with_title.erb
|
|
719
741
|
- lib/capybara/spec/views/with_unload_alert.erb
|
|
720
742
|
- lib/capybara/spec/views/with_windows.erb
|
|
721
743
|
- lib/capybara/spec/views/within_frames.erb
|
|
@@ -765,7 +787,8 @@ licenses:
|
|
|
765
787
|
metadata:
|
|
766
788
|
changelog_uri: https://github.com/teamcapybara/capybara/blob/master/History.md
|
|
767
789
|
source_code_uri: https://github.com/teamcapybara/capybara
|
|
768
|
-
|
|
790
|
+
rubygems_mfa_required: 'true'
|
|
791
|
+
post_install_message:
|
|
769
792
|
rdoc_options: []
|
|
770
793
|
require_paths:
|
|
771
794
|
- lib
|
|
@@ -773,15 +796,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
773
796
|
requirements:
|
|
774
797
|
- - ">="
|
|
775
798
|
- !ruby/object:Gem::Version
|
|
776
|
-
version: 2.
|
|
799
|
+
version: 2.7.0
|
|
777
800
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
778
801
|
requirements:
|
|
779
802
|
- - ">="
|
|
780
803
|
- !ruby/object:Gem::Version
|
|
781
804
|
version: '0'
|
|
782
805
|
requirements: []
|
|
783
|
-
rubygems_version: 3.
|
|
784
|
-
signing_key:
|
|
806
|
+
rubygems_version: 3.3.7
|
|
807
|
+
signing_key:
|
|
785
808
|
specification_version: 4
|
|
786
809
|
summary: Capybara aims to simplify the process of integration testing Rack applications,
|
|
787
810
|
such as Rails, Sinatra or Merb
|