capybara 3.12.0 → 3.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +27 -0
- data/README.md +13 -3
- data/lib/capybara/config.rb +3 -1
- data/lib/capybara/driver/base.rb +2 -2
- data/lib/capybara/driver/node.rb +11 -2
- data/lib/capybara/minitest/spec.rb +10 -3
- data/lib/capybara/minitest.rb +3 -3
- data/lib/capybara/node/actions.rb +4 -0
- data/lib/capybara/node/base.rb +13 -5
- data/lib/capybara/node/document.rb +12 -0
- data/lib/capybara/node/element.rb +37 -0
- data/lib/capybara/node/finders.rb +1 -0
- data/lib/capybara/node/matchers.rb +19 -4
- data/lib/capybara/node/simple.rb +7 -2
- data/lib/capybara/queries/selector_query.rb +93 -9
- data/lib/capybara/rspec/matchers/become_closed.rb +1 -1
- data/lib/capybara/rspec/matchers/match_style.rb +38 -0
- data/lib/capybara/rspec/matchers.rb +11 -3
- data/lib/capybara/selector/selector.rb +47 -3
- data/lib/capybara/selector.rb +30 -30
- data/lib/capybara/selenium/driver.rb +12 -11
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +3 -3
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -2
- data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +13 -0
- data/lib/capybara/selenium/extensions/find.rb +87 -0
- data/lib/capybara/selenium/extensions/scroll.rb +78 -0
- data/lib/capybara/selenium/node.rb +52 -28
- data/lib/capybara/session.rb +13 -1
- data/lib/capybara/spec/public/test.js +1 -0
- data/lib/capybara/spec/session/assert_style_spec.rb +4 -4
- data/lib/capybara/spec/session/attach_file_spec.rb +6 -6
- data/lib/capybara/spec/session/click_button_spec.rb +1 -1
- data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -0
- data/lib/capybara/spec/session/execute_script_spec.rb +1 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +7 -1
- data/lib/capybara/spec/session/find_field_spec.rb +1 -1
- data/lib/capybara/spec/session/find_spec.rb +11 -0
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +0 -1
- data/lib/capybara/spec/session/has_css_spec.rb +32 -0
- data/lib/capybara/spec/session/has_select_spec.rb +2 -2
- data/lib/capybara/spec/session/has_selector_spec.rb +7 -0
- data/lib/capybara/spec/session/has_text_spec.rb +1 -1
- data/lib/capybara/spec/session/matches_style_spec.rb +35 -0
- data/lib/capybara/spec/session/scroll_spec.rb +117 -0
- data/lib/capybara/spec/session/select_spec.rb +5 -0
- data/lib/capybara/spec/spec_helper.rb +1 -0
- data/lib/capybara/spec/views/obscured.erb +1 -1
- data/lib/capybara/spec/views/scroll.erb +20 -0
- data/lib/capybara/spec/views/with_html.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +1 -1
- data/lib/capybara.rb +8 -4
- data/spec/basic_node_spec.rb +11 -0
- data/spec/dsl_spec.rb +3 -1
- data/spec/minitest_spec.rb +2 -2
- data/spec/minitest_spec_spec.rb +1 -1
- data/spec/rack_test_spec.rb +4 -1
- data/spec/result_spec.rb +2 -2
- data/spec/selector_spec.rb +11 -1
- data/spec/selenium_spec_firefox.rb +1 -1
- data/spec/selenium_spec_ie.rb +70 -9
- data/spec/session_spec.rb +9 -0
- data/spec/shared_selenium_session.rb +4 -3
- data/spec/spec_helper.rb +2 -0
- metadata +38 -6
- data/lib/capybara/rspec/matchers/have_style.rb +0 -23
- data/lib/capybara/spec/session/has_style_spec.rb +0 -25
data/lib/capybara/window.rb
CHANGED
data/lib/capybara.rb
CHANGED
|
@@ -38,6 +38,8 @@ module Capybara
|
|
|
38
38
|
# See {Capybara.configure}
|
|
39
39
|
# @!method javascript_driver
|
|
40
40
|
# See {Capybara.configure}
|
|
41
|
+
# @!method allow_gumbo
|
|
42
|
+
# See {Capybara.configure}
|
|
41
43
|
Config::OPTIONS.each do |method|
|
|
42
44
|
def_delegators :config, method, "#{method}="
|
|
43
45
|
end
|
|
@@ -86,6 +88,7 @@ module Capybara
|
|
|
86
88
|
# [test_id = Symbol/String/nil] Optional attribute to match locator aginst with builtin selectors along with id (Default: nil)
|
|
87
89
|
# [predicates_wait = Boolean] Whether Capybaras predicate matchers use waiting behavior by default (Default: true)
|
|
88
90
|
# [default_normalize_ws = Boolean] Whether text predicates and matchers use normalize whitespace behaviour (Default: false)
|
|
91
|
+
# [allow_gumbo = Boolean] When `nokogumbo` is available, whether it will be used to parse HTML strings (Default: false)
|
|
89
92
|
#
|
|
90
93
|
# === DSL Options
|
|
91
94
|
#
|
|
@@ -162,8 +165,8 @@ module Capybara
|
|
|
162
165
|
# @param [Symbol] name The name of the selector to add
|
|
163
166
|
# @yield A block executed in the context of the new {Capybara::Selector}
|
|
164
167
|
#
|
|
165
|
-
def add_selector(name, &block)
|
|
166
|
-
Capybara::Selector.add(name, &block)
|
|
168
|
+
def add_selector(name, **options, &block)
|
|
169
|
+
Capybara::Selector.add(name, **options, &block)
|
|
167
170
|
end
|
|
168
171
|
|
|
169
172
|
##
|
|
@@ -173,7 +176,7 @@ module Capybara
|
|
|
173
176
|
# button style (a class) might look like this
|
|
174
177
|
#
|
|
175
178
|
# Capybara.modify_selector(:button) do
|
|
176
|
-
# filter (:
|
|
179
|
+
# filter (:btn_style, valid_values: [:primary, :secondary]) { |node, style| node[:class].split.include? "btn-#{style}" }
|
|
177
180
|
# end
|
|
178
181
|
#
|
|
179
182
|
#
|
|
@@ -366,7 +369,7 @@ module Capybara
|
|
|
366
369
|
# @return [Nokogiri::HTML::Document] HTML document
|
|
367
370
|
#
|
|
368
371
|
def HTML(html) # rubocop:disable Naming/MethodName
|
|
369
|
-
if Nokogiri.respond_to?(:HTML5) # Nokogumbo installed
|
|
372
|
+
if Nokogiri.respond_to?(:HTML5) && Capybara.allow_gumbo # Nokogumbo installed and allowed for use
|
|
370
373
|
Nokogiri::HTML5(html).tap do |document|
|
|
371
374
|
document.xpath('//textarea').each do |textarea|
|
|
372
375
|
# The Nokogumbo HTML5 parser already returns spec compliant contents
|
|
@@ -522,6 +525,7 @@ Capybara.configure do |config|
|
|
|
522
525
|
config.test_id = nil
|
|
523
526
|
config.predicates_wait = true
|
|
524
527
|
config.default_normalize_ws = false
|
|
528
|
+
config.allow_gumbo = false
|
|
525
529
|
end
|
|
526
530
|
|
|
527
531
|
Capybara.register_driver :rack_test do |app|
|
data/spec/basic_node_spec.rb
CHANGED
|
@@ -110,6 +110,17 @@ RSpec.describe Capybara do
|
|
|
110
110
|
expect(string.find('//form/input[@name="meh"]')).not_to be_disabled
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
+
it 'drops illegal fragments when using gumbo' do
|
|
114
|
+
skip 'libxml is less strict than Gumbo' unless Nokogiri.respond_to?(:HTML5)
|
|
115
|
+
expect(Capybara.string('<td>1</td>')).not_to have_css('td')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'can disable use of gumbo' do
|
|
119
|
+
skip "Test doesn't make sense unlesss nokogumbo is loaded" unless Nokogiri.respond_to?(:HTML5)
|
|
120
|
+
Capybara.allow_gumbo = false
|
|
121
|
+
expect(Capybara.string('<td>1</td>')).to have_css('td')
|
|
122
|
+
end
|
|
123
|
+
|
|
113
124
|
describe '#title' do
|
|
114
125
|
it 'returns the page title' do
|
|
115
126
|
expect(string.title).to eq('simple_node')
|
data/spec/dsl_spec.rb
CHANGED
|
@@ -8,11 +8,13 @@ class TestClass
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
Capybara::SpecHelper.run_specs TestClass.new, 'DSL', capybara_skip: %i[
|
|
11
|
-
js modals screenshot frames windows send_keys server hover about_scheme psc download css driver
|
|
11
|
+
js modals screenshot frames windows send_keys server hover about_scheme psc download css driver scroll
|
|
12
12
|
] do |example|
|
|
13
13
|
case example.metadata[:full_description]
|
|
14
14
|
when /has_css\? should support case insensitive :class and :id options/
|
|
15
15
|
pending "Nokogiri doesn't support case insensitive CSS attribute matchers"
|
|
16
|
+
when /#click_button should follow permanent redirects that maintain method/
|
|
17
|
+
pending "Rack < 2 doesn't support 308" if Gem.loaded_specs['rack'].version < Gem::Version.new('2.0.0')
|
|
16
18
|
end
|
|
17
19
|
end
|
|
18
20
|
|
data/spec/minitest_spec.rb
CHANGED
|
@@ -125,10 +125,10 @@ class MinitestTest < Minitest::Test
|
|
|
125
125
|
refute_matches_xpath(find(:select, 'form_title'), './/select[@id="form_other_title"]')
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
def
|
|
128
|
+
def test_assert_matches_style
|
|
129
129
|
skip "Rack test doesn't support style" if Capybara.current_driver == :rack_test
|
|
130
130
|
visit('/with_html')
|
|
131
|
-
|
|
131
|
+
assert_matches_style(find(:css, '#second'), display: 'inline')
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
data/spec/minitest_spec_spec.rb
CHANGED
|
@@ -124,7 +124,7 @@ class MinitestSpecTest < Minitest::Spec
|
|
|
124
124
|
it 'supports style expectations' do
|
|
125
125
|
skip "Rack test doesn't support style" if Capybara.current_driver == :rack_test
|
|
126
126
|
visit('/with_html')
|
|
127
|
-
find(:css, '#second').
|
|
127
|
+
find(:css, '#second').must_match_style('display' => 'inline')
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
|
data/spec/rack_test_spec.rb
CHANGED
|
@@ -24,11 +24,14 @@ skipped_tests = %i[
|
|
|
24
24
|
about_scheme
|
|
25
25
|
download
|
|
26
26
|
css
|
|
27
|
+
scroll
|
|
27
28
|
]
|
|
28
29
|
Capybara::SpecHelper.run_specs TestSessions::RackTest, 'RackTest', capybara_skip: skipped_tests do |example|
|
|
29
30
|
case example.metadata[:full_description]
|
|
30
31
|
when /has_css\? should support case insensitive :class and :id options/
|
|
31
|
-
|
|
32
|
+
skip "Nokogiri doesn't support case insensitive CSS attribute matchers"
|
|
33
|
+
when /#click_button should follow permanent redirects that maintain method/
|
|
34
|
+
skip "Rack < 2 doesn't support 308" if Gem.loaded_specs['rack'].version < Gem::Version.new('2.0.0')
|
|
32
35
|
end
|
|
33
36
|
end
|
|
34
37
|
|
data/spec/result_spec.rb
CHANGED
|
@@ -88,7 +88,7 @@ RSpec.describe Capybara::Result do
|
|
|
88
88
|
it 'should catch invalid element errors during filtering' do
|
|
89
89
|
allow_any_instance_of(Capybara::Node::Simple).to receive(:text).and_raise(StandardError)
|
|
90
90
|
allow_any_instance_of(Capybara::Node::Simple).to receive(:session).and_return(
|
|
91
|
-
instance_double('Capybara::Session', driver: instance_double('Capybara::Driver::Base', invalid_element_errors: [StandardError]))
|
|
91
|
+
instance_double('Capybara::Session', driver: instance_double('Capybara::Driver::Base', invalid_element_errors: [StandardError], wait?: false))
|
|
92
92
|
)
|
|
93
93
|
result = string.all('//li', text: 'Alpha')
|
|
94
94
|
expect(result.size).to eq 0
|
|
@@ -97,7 +97,7 @@ RSpec.describe Capybara::Result do
|
|
|
97
97
|
it 'should return non-invalid element errors during filtering' do
|
|
98
98
|
allow_any_instance_of(Capybara::Node::Simple).to receive(:text).and_raise(StandardError)
|
|
99
99
|
allow_any_instance_of(Capybara::Node::Simple).to receive(:session).and_return(
|
|
100
|
-
instance_double('Capybara::Session', driver: instance_double('Capybara::Driver::Base', invalid_element_errors: [ArgumentError]))
|
|
100
|
+
instance_double('Capybara::Session', driver: instance_double('Capybara::Driver::Base', invalid_element_errors: [ArgumentError], wait?: false))
|
|
101
101
|
)
|
|
102
102
|
expect do
|
|
103
103
|
string.all('//li', text: 'Alpha').to_a
|
data/spec/selector_spec.rb
CHANGED
|
@@ -31,7 +31,7 @@ RSpec.describe Capybara do
|
|
|
31
31
|
<input type="file" id="file" class=".special file"/>
|
|
32
32
|
<input type="hidden" id="hidden_field" value="this is hidden"/>
|
|
33
33
|
<input type="submit" value="click me" title="submit button"/>
|
|
34
|
-
<input type="button" value="don't click me" title="Other button 1"/>
|
|
34
|
+
<input type="button" value="don't click me" title="Other button 1" style="line-height: 30px;"/>
|
|
35
35
|
<a href="#">link</a>
|
|
36
36
|
<fieldset></fieldset>
|
|
37
37
|
<select id="select">
|
|
@@ -304,6 +304,16 @@ RSpec.describe Capybara do
|
|
|
304
304
|
end
|
|
305
305
|
end
|
|
306
306
|
|
|
307
|
+
context 'with :style option' do
|
|
308
|
+
it 'accepts string for CSS based selectors' do
|
|
309
|
+
expect(string.find(:custom_css_selector, 'input', style: 'line-height: 30px;')[:title]).to eq 'Other button 1'
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
it 'accepts Regexp for CSS base selectors' do
|
|
313
|
+
expect(string.find(:custom_css_selector, 'input', style: /30px/)[:title]).to eq 'Other button 1'
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
|
|
307
317
|
# :css, :xpath, :id, :field, :fieldset, :link, :button, :link_or_button, :fillable_field, :radio_button, :checkbox, :select,
|
|
308
318
|
# :option, :file_field, :label, :table, :frame
|
|
309
319
|
|
data/spec/selenium_spec_ie.rb
CHANGED
|
@@ -5,16 +5,49 @@ require 'selenium-webdriver'
|
|
|
5
5
|
require 'shared_selenium_session'
|
|
6
6
|
require 'rspec/shared_spec_matchers'
|
|
7
7
|
|
|
8
|
+
::Selenium::WebDriver::IE.driver_path = 'C:\Tools\WebDriver\IEDriverServer.exe' if ENV['CI']
|
|
9
|
+
|
|
10
|
+
def selenium_host
|
|
11
|
+
ENV.fetch('SELENIUM_HOST', '192.168.56.102')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def selenium_port
|
|
15
|
+
ENV.fetch('SELENIUM_PORT', 4444)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def server_host
|
|
19
|
+
ENV.fetch('SERVER_HOST', '10.24.4.135')
|
|
20
|
+
end
|
|
21
|
+
|
|
8
22
|
Capybara.register_driver :selenium_ie do |app|
|
|
9
23
|
# ::Selenium::WebDriver.logger.level = "debug"
|
|
10
24
|
options = ::Selenium::WebDriver::IE::Options.new
|
|
11
25
|
options.require_window_focus = true
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
# options.add_option("log", {"level": "trace"})
|
|
27
|
+
|
|
28
|
+
if ENV['REMOTE']
|
|
29
|
+
Capybara.server_host = server_host
|
|
30
|
+
|
|
31
|
+
url = "http://#{selenium_host}:#{selenium_port}/wd/hub"
|
|
32
|
+
Capybara::Selenium::Driver.new(app,
|
|
33
|
+
browser: :remote,
|
|
34
|
+
options: options,
|
|
35
|
+
url: url).tap do |driver|
|
|
36
|
+
puts driver.browser.capabilities.inspect
|
|
37
|
+
driver.browser.file_detector = lambda do |args|
|
|
38
|
+
str = args.first.to_s
|
|
39
|
+
str if File.exist?(str)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
else
|
|
43
|
+
Capybara::Selenium::Driver.new(
|
|
44
|
+
app,
|
|
45
|
+
browser: :ie,
|
|
46
|
+
options: options
|
|
47
|
+
).tap do |driver|
|
|
48
|
+
puts driver.browser.capabilities.inspect
|
|
49
|
+
end
|
|
50
|
+
end
|
|
18
51
|
end
|
|
19
52
|
|
|
20
53
|
module TestSessions
|
|
@@ -41,12 +74,36 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_sk
|
|
|
41
74
|
skip 'IE 11 obeys non-standard disabled attribute on anchor tag'
|
|
42
75
|
when /#right_click should allow modifiers$/
|
|
43
76
|
skip "Windows can't :meta click because :meta triggers start menu"
|
|
77
|
+
when /#click should allow modifiers$/
|
|
78
|
+
pending "Doesn't work with IE for some unknown reason$"
|
|
79
|
+
when /#double_click should allow modifiers$/
|
|
80
|
+
pending "Doesn't work with IE for some unknown reason$"
|
|
44
81
|
when /#click should allow multiple modifiers$/
|
|
45
82
|
skip "Windows can't :meta click because :meta triggers start menu"
|
|
46
83
|
when /#double_click should allow multiple modifiers$/
|
|
47
84
|
skip "Windows can't :alt double click due to being properties shortcut"
|
|
48
|
-
when
|
|
49
|
-
pending '
|
|
85
|
+
when /#has_css\? should support case insensitive :class and :id options$/
|
|
86
|
+
pending "IE doesn't support case insensitive CSS selectors"
|
|
87
|
+
when /#reset_session! removes ALL cookies$/
|
|
88
|
+
pending "IE driver doesn't provide a way to remove ALL cookies"
|
|
89
|
+
when /#click_button should send button in document order$/
|
|
90
|
+
pending "IE 11 doesn't support the 'form' attribute"
|
|
91
|
+
when /#click_button should follow permanent redirects that maintain method$/
|
|
92
|
+
pending "Window 7 and 8.1 don't support 308 http status code"
|
|
93
|
+
when /#scroll_to can scroll an element to the center of the viewport$/,
|
|
94
|
+
/#scroll_to can scroll an element to the center of the scrolling element$/
|
|
95
|
+
pending " IE doesn't support ScrollToOptions"
|
|
96
|
+
when /#attach_file with multipart form should fire change once for each set of files uploaded$/,
|
|
97
|
+
/#attach_file with multipart form should fire change once when uploading multiple files from empty$/,
|
|
98
|
+
/#attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files$/
|
|
99
|
+
pending "IE requires all files be uploaded from same directory. Selenium doesn't provide that." if ENV['REMOTE']
|
|
100
|
+
when %r{#attach_file with multipart form should send content type image/jpeg when uploading an image$}
|
|
101
|
+
pending 'IE gets text/plain type for some reason'
|
|
102
|
+
# when /#click should not retry clicking when wait is disabled$/
|
|
103
|
+
# Fixed in IEDriverServer 3.141.0.5
|
|
104
|
+
# pending "IE driver doesn't error when clicking on covered elements, it just clicks the wrong element"
|
|
105
|
+
when /#click should go to the same page if href is blank$/
|
|
106
|
+
pending 'IE treats blank href as a parent request (against HTML spec)'
|
|
50
107
|
end
|
|
51
108
|
end
|
|
52
109
|
|
|
@@ -58,13 +115,16 @@ end
|
|
|
58
115
|
|
|
59
116
|
RSpec.describe Capybara::Selenium::Node do
|
|
60
117
|
it '#right_click should allow modifiers' do
|
|
118
|
+
# pending "Actions API doesn't appear to work for this"
|
|
61
119
|
session = TestSessions::SeleniumIE
|
|
62
120
|
session.visit('/with_js')
|
|
63
|
-
session.find(:css, '#click-test')
|
|
121
|
+
el = session.find(:css, '#click-test')
|
|
122
|
+
el.right_click(:control)
|
|
64
123
|
expect(session).to have_link('Has been control right clicked')
|
|
65
124
|
end
|
|
66
125
|
|
|
67
126
|
it '#click should allow multiple modifiers' do
|
|
127
|
+
# pending "Actions API doesn't appear to work for this"
|
|
68
128
|
session = TestSessions::SeleniumIE
|
|
69
129
|
session.visit('with_js')
|
|
70
130
|
# IE triggers system behavior with :meta so can't use those here
|
|
@@ -73,6 +133,7 @@ RSpec.describe Capybara::Selenium::Node do
|
|
|
73
133
|
end
|
|
74
134
|
|
|
75
135
|
it '#double_click should allow modifiers' do
|
|
136
|
+
# pending "Actions API doesn't appear to work for this"
|
|
76
137
|
session = TestSessions::SeleniumIE
|
|
77
138
|
session.visit('/with_js')
|
|
78
139
|
session.find(:css, '#click-test').double_click(:shift)
|
data/spec/session_spec.rb
CHANGED
|
@@ -72,4 +72,13 @@ RSpec.describe Capybara::Session do
|
|
|
72
72
|
expect(Capybara.session_name).to eq 'sess1'
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
|
+
|
|
76
|
+
context 'quit' do
|
|
77
|
+
it 'will reset the driver' do
|
|
78
|
+
session = Capybara::Session.new(:rack_test, TestApp)
|
|
79
|
+
driver = session.driver
|
|
80
|
+
session.quit
|
|
81
|
+
expect(session.driver).not_to eql driver
|
|
82
|
+
end
|
|
83
|
+
end
|
|
75
84
|
end
|
|
@@ -199,14 +199,14 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
199
199
|
# this is here because it is testing for an XPath that is specific to the algorithm used in the selenium driver
|
|
200
200
|
session.visit('/path')
|
|
201
201
|
element = session.find(:link, 'Second Link')
|
|
202
|
-
expect(element.path).to eq('/HTML/BODY/DIV[2]/A[1]')
|
|
202
|
+
expect(element.path).to eq('/HTML/BODY[1]/DIV[2]/A[1]')
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
it 'handles namespaces in xhtml' do
|
|
206
206
|
pending "IE 11 doesn't handle all XPath querys (namespace-uri, etc)" if ie?(session)
|
|
207
207
|
session.visit '/with_namespace'
|
|
208
208
|
rect = session.find(:css, 'div svg rect:first-of-type')
|
|
209
|
-
expect(rect.path).to eq("/HTML/BODY/DIV
|
|
209
|
+
expect(rect.path).to eq("/HTML/BODY[1]/DIV[1]/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg'][1]/*[local-name()='rect' and namespace-uri()='http://www.w3.org/2000/svg'][1]")
|
|
210
210
|
expect(session.find(:xpath, rect.path)).to eq rect
|
|
211
211
|
end
|
|
212
212
|
|
|
@@ -214,7 +214,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
214
214
|
pending "IE 11 doesn't handle all XPath querys (namespace-uri, etc)" if ie?(session)
|
|
215
215
|
session.visit '/with_html5_svg'
|
|
216
216
|
rect = session.find(:css, 'div svg rect:first-of-type')
|
|
217
|
-
expect(rect.path).to eq("/HTML/BODY/DIV
|
|
217
|
+
expect(rect.path).to eq("/HTML/BODY[1]/DIV[1]/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg'][1]/*[local-name()='rect' and namespace-uri()='http://www.w3.org/2000/svg'][1]")
|
|
218
218
|
expect(session.find(:xpath, rect.path)).to eq rect
|
|
219
219
|
end
|
|
220
220
|
|
|
@@ -339,6 +339,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
|
339
339
|
pending "Geckodriver doesn't support uploading a directory" if firefox?(session)
|
|
340
340
|
pending "Selenium remote doesn't support transferring a directory" if remote?(session)
|
|
341
341
|
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['HEADLESS']
|
|
342
|
+
pending "IE doesn't support uploading a directory" if ie?(session)
|
|
342
343
|
|
|
343
344
|
session.visit('/form')
|
|
344
345
|
@test_file_dir = File.expand_path('./fixtures', File.dirname(__FILE__))
|
data/spec/spec_helper.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'rspec/expectations'
|
|
4
4
|
require 'capybara/spec/spec_helper'
|
|
5
5
|
require 'webdrivers' if ENV['CI']
|
|
6
|
+
require 'selenium_statistics'
|
|
6
7
|
|
|
7
8
|
module Capybara
|
|
8
9
|
module SpecHelper
|
|
@@ -53,4 +54,5 @@ RSpec.configure do |config|
|
|
|
53
54
|
Capybara::SpecHelper.configure(config)
|
|
54
55
|
config.filter_run_including focus_: true unless ENV['CI']
|
|
55
56
|
config.run_all_when_everything_filtered = true
|
|
57
|
+
config.after(:suite) { SeleniumStatistics.print_results }
|
|
56
58
|
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.13.2
|
|
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: 2019-01-24 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: addressable
|
|
@@ -166,6 +166,20 @@ dependencies:
|
|
|
166
166
|
- - ">="
|
|
167
167
|
- !ruby/object:Gem::Version
|
|
168
168
|
version: 1.0.0
|
|
169
|
+
- !ruby/object:Gem::Dependency
|
|
170
|
+
name: irb
|
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
|
172
|
+
requirements:
|
|
173
|
+
- - ">="
|
|
174
|
+
- !ruby/object:Gem::Version
|
|
175
|
+
version: '0'
|
|
176
|
+
type: :development
|
|
177
|
+
prerelease: false
|
|
178
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
179
|
+
requirements:
|
|
180
|
+
- - ">="
|
|
181
|
+
- !ruby/object:Gem::Version
|
|
182
|
+
version: '0'
|
|
169
183
|
- !ruby/object:Gem::Dependency
|
|
170
184
|
name: launchy
|
|
171
185
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -278,6 +292,20 @@ dependencies:
|
|
|
278
292
|
- - "~>"
|
|
279
293
|
- !ruby/object:Gem::Version
|
|
280
294
|
version: '3.5'
|
|
295
|
+
- !ruby/object:Gem::Dependency
|
|
296
|
+
name: selenium_statistics
|
|
297
|
+
requirement: !ruby/object:Gem::Requirement
|
|
298
|
+
requirements:
|
|
299
|
+
- - ">="
|
|
300
|
+
- !ruby/object:Gem::Version
|
|
301
|
+
version: '0'
|
|
302
|
+
type: :development
|
|
303
|
+
prerelease: false
|
|
304
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
305
|
+
requirements:
|
|
306
|
+
- - ">="
|
|
307
|
+
- !ruby/object:Gem::Version
|
|
308
|
+
version: '0'
|
|
281
309
|
- !ruby/object:Gem::Dependency
|
|
282
310
|
name: sinatra
|
|
283
311
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -360,10 +388,10 @@ files:
|
|
|
360
388
|
- lib/capybara/rspec/matchers/compound.rb
|
|
361
389
|
- lib/capybara/rspec/matchers/have_current_path.rb
|
|
362
390
|
- lib/capybara/rspec/matchers/have_selector.rb
|
|
363
|
-
- lib/capybara/rspec/matchers/have_style.rb
|
|
364
391
|
- lib/capybara/rspec/matchers/have_text.rb
|
|
365
392
|
- lib/capybara/rspec/matchers/have_title.rb
|
|
366
393
|
- lib/capybara/rspec/matchers/match_selector.rb
|
|
394
|
+
- lib/capybara/rspec/matchers/match_style.rb
|
|
367
395
|
- lib/capybara/selector.rb
|
|
368
396
|
- lib/capybara/selector/builders/css_builder.rb
|
|
369
397
|
- lib/capybara/selector/builders/xpath_builder.rb
|
|
@@ -379,7 +407,10 @@ files:
|
|
|
379
407
|
- lib/capybara/selenium/driver.rb
|
|
380
408
|
- lib/capybara/selenium/driver_specializations/chrome_driver.rb
|
|
381
409
|
- lib/capybara/selenium/driver_specializations/firefox_driver.rb
|
|
410
|
+
- lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb
|
|
411
|
+
- lib/capybara/selenium/extensions/find.rb
|
|
382
412
|
- lib/capybara/selenium/extensions/html5_drag.rb
|
|
413
|
+
- lib/capybara/selenium/extensions/scroll.rb
|
|
383
414
|
- lib/capybara/selenium/node.rb
|
|
384
415
|
- lib/capybara/selenium/nodes/chrome_node.rb
|
|
385
416
|
- lib/capybara/selenium/nodes/firefox_node.rb
|
|
@@ -450,13 +481,13 @@ files:
|
|
|
450
481
|
- lib/capybara/spec/session/has_none_selectors_spec.rb
|
|
451
482
|
- lib/capybara/spec/session/has_select_spec.rb
|
|
452
483
|
- lib/capybara/spec/session/has_selector_spec.rb
|
|
453
|
-
- lib/capybara/spec/session/has_style_spec.rb
|
|
454
484
|
- lib/capybara/spec/session/has_table_spec.rb
|
|
455
485
|
- lib/capybara/spec/session/has_text_spec.rb
|
|
456
486
|
- lib/capybara/spec/session/has_title_spec.rb
|
|
457
487
|
- lib/capybara/spec/session/has_xpath_spec.rb
|
|
458
488
|
- lib/capybara/spec/session/headers_spec.rb
|
|
459
489
|
- lib/capybara/spec/session/html_spec.rb
|
|
490
|
+
- lib/capybara/spec/session/matches_style_spec.rb
|
|
460
491
|
- lib/capybara/spec/session/node_spec.rb
|
|
461
492
|
- lib/capybara/spec/session/node_wrapper_spec.rb
|
|
462
493
|
- lib/capybara/spec/session/refresh_spec.rb
|
|
@@ -467,6 +498,7 @@ files:
|
|
|
467
498
|
- lib/capybara/spec/session/save_page_spec.rb
|
|
468
499
|
- lib/capybara/spec/session/save_screenshot_spec.rb
|
|
469
500
|
- lib/capybara/spec/session/screenshot_spec.rb
|
|
501
|
+
- lib/capybara/spec/session/scroll_spec.rb
|
|
470
502
|
- lib/capybara/spec/session/select_spec.rb
|
|
471
503
|
- lib/capybara/spec/session/selectors_spec.rb
|
|
472
504
|
- lib/capybara/spec/session/sibling_spec.rb
|
|
@@ -502,6 +534,7 @@ files:
|
|
|
502
534
|
- lib/capybara/spec/views/popup_one.erb
|
|
503
535
|
- lib/capybara/spec/views/popup_two.erb
|
|
504
536
|
- lib/capybara/spec/views/postback.erb
|
|
537
|
+
- lib/capybara/spec/views/scroll.erb
|
|
505
538
|
- lib/capybara/spec/views/tables.erb
|
|
506
539
|
- lib/capybara/spec/views/with_animation.erb
|
|
507
540
|
- lib/capybara/spec/views/with_base_tag.erb
|
|
@@ -578,8 +611,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
578
611
|
- !ruby/object:Gem::Version
|
|
579
612
|
version: '0'
|
|
580
613
|
requirements: []
|
|
581
|
-
|
|
582
|
-
rubygems_version: 2.7.8
|
|
614
|
+
rubygems_version: 3.0.1
|
|
583
615
|
signing_key:
|
|
584
616
|
specification_version: 4
|
|
585
617
|
summary: Capybara aims to simplify the process of integration testing Rack applications,
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'capybara/rspec/matchers/base'
|
|
4
|
-
|
|
5
|
-
module Capybara
|
|
6
|
-
module RSpecMatchers
|
|
7
|
-
module Matchers
|
|
8
|
-
class HaveStyle < WrappedElementMatcher
|
|
9
|
-
def element_matches?(el)
|
|
10
|
-
el.assert_style(*@args)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def does_not_match?(_actual)
|
|
14
|
-
raise ArgumentError, 'The have_style matcher does not support use with not_to/should_not'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def description
|
|
18
|
-
'have style'
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
Capybara::SpecHelper.spec '#has_style?', requires: [:css] do
|
|
4
|
-
before do
|
|
5
|
-
@session.visit('/with_html')
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it 'should be true if the element has the given style' do
|
|
9
|
-
expect(@session.find(:css, '#first')).to have_style(display: 'block')
|
|
10
|
-
expect(@session.find(:css, '#first').has_style?(display: 'block')).to be true
|
|
11
|
-
expect(@session.find(:css, '#second')).to have_style('display' => 'inline')
|
|
12
|
-
expect(@session.find(:css, '#second').has_style?('display' => 'inline')).to be true
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'should be false if the element does not have the given style' do
|
|
16
|
-
expect(@session.find(:css, '#first').has_style?('display' => 'inline')).to be false
|
|
17
|
-
expect(@session.find(:css, '#second').has_style?(display: 'block')).to be false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'allows Regexp for value matching' do
|
|
21
|
-
expect(@session.find(:css, '#first')).to have_style(display: /^bl/)
|
|
22
|
-
expect(@session.find(:css, '#first').has_style?('display' => /^bl/)).to be true
|
|
23
|
-
expect(@session.find(:css, '#first').has_style?(display: /^in/)).to be false
|
|
24
|
-
end
|
|
25
|
-
end
|