capybara 3.12.0 → 3.13.0
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 +13 -0
- data/README.md +13 -3
- data/lib/capybara.rb +8 -4
- 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.rb +3 -3
- data/lib/capybara/minitest/spec.rb +10 -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.rb +11 -3
- data/lib/capybara/rspec/matchers/become_closed.rb +1 -1
- data/lib/capybara/rspec/matchers/match_style.rb +38 -0
- data/lib/capybara/selector.rb +30 -30
- data/lib/capybara/selector/selector.rb +47 -3
- 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 +81 -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/spec/basic_node_spec.rb +11 -0
- data/spec/dsl_spec.rb +1 -1
- data/spec/minitest_spec.rb +2 -2
- data/spec/minitest_spec_spec.rb +1 -1
- data/spec/rack_test_spec.rb +1 -0
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da79991ce86301cce84e97c31e9c46424309edfaaef6c1f52316d78408673340
|
4
|
+
data.tar.gz: 0dbf02750a107ebc011c9899a60e5958099444f897cca384607919b58554dc9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3718591ef61c25cadb6de5048b73095340b2fa983d0f978e016ec3da1348ea88bcac5797e717b2c8053e2804b7b94aa27b46e3b57ce40fcdfa33cf70fca43d52
|
7
|
+
data.tar.gz: 5cf850913d7c0624002f969bfc3c87661a30b475b9a35decb2d607a7be82456f406f1c3490a803d30cd3f573dccdece7ad66ef8d46be36a347476af01f9ce7b8
|
data/History.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# Version 3.13.0
|
2
|
+
Release date: 2019-01-23
|
3
|
+
|
4
|
+
### Added
|
5
|
+
|
6
|
+
* Session#quit added
|
7
|
+
* #scroll_to added to allow scrolling page/elements to specified locations
|
8
|
+
* Speed optimizations around multiple element location and path generation when using the Selenium driver
|
9
|
+
* Support for locator type checking in custom selectors
|
10
|
+
* Allow configuration of gumbo use - defaults to off
|
11
|
+
* `assert_style`/`has_style`/`have_style` depreacted in favor of `assert_matches_style`/`matches_styles?`/`match_style`
|
12
|
+
* :style filter added to selectors
|
13
|
+
|
1
14
|
# Version 3.12.0
|
2
15
|
Release date: 2018-11-28
|
3
16
|
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
7
7
|
[](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
|
8
8
|
|
9
|
-
**Note** You are viewing the README for the 3.
|
9
|
+
**Note** You are viewing the README for the version 3.13.x of Capybara.
|
10
10
|
|
11
11
|
Capybara helps you test web applications by simulating how a real user would
|
12
12
|
interact with your app. It is agnostic about the driver running your tests and
|
@@ -35,6 +35,7 @@ GitHub): http://groups.google.com/group/ruby-capybara
|
|
35
35
|
- [Selecting the Driver](#selecting-the-driver)
|
36
36
|
- [RackTest](#racktest)
|
37
37
|
- [Selenium](#selenium)
|
38
|
+
- [Apparition](#apparition)
|
38
39
|
- [Capybara-webkit](#capybara-webkit)
|
39
40
|
- [Poltergeist](#poltergeist)
|
40
41
|
- [The DSL](#the-dsl)
|
@@ -217,7 +218,7 @@ feature "Signing in" do
|
|
217
218
|
end
|
218
219
|
```
|
219
220
|
|
220
|
-
`feature` is in fact just an alias for `describe ..., type
|
221
|
+
`feature` is in fact just an alias for `describe ..., type: :feature`,
|
221
222
|
`background` is an alias for `before`, `scenario` for `it`, and
|
222
223
|
`given`/`given!` aliases for `let`/`let!`, respectively.
|
223
224
|
|
@@ -406,6 +407,15 @@ to the browsers. See the section on adding and configuring drivers.
|
|
406
407
|
same transaction as your tests, causing data not to be shared between your test
|
407
408
|
and test server, see [Transactions and database setup](#transactions-and-database-setup) below.
|
408
409
|
|
410
|
+
### <a name="apparition"></a>Apparition
|
411
|
+
|
412
|
+
The [apparition driver](https://github.com/twalpole/apparition) in a new driver thatallows you to run tests using Chrome in a headless
|
413
|
+
or headed configuration. It attempts to provide backwards compatibility with the [Poltergeist driver API](https://github.com/teampoltergeist/poltergeist)
|
414
|
+
while allowing for the use of modern JS/CSS. It uses CDP to communicate with Chrome, thereby obviating the need for chromedriver.
|
415
|
+
A compatibility layer for capybara-webkit is planned, although has not yet been started. This driver is being developed by the
|
416
|
+
maintainer of Capybara and will attempt to keep up to date with new Capybara releases. It will probably be moved into the
|
417
|
+
teamcapybara repo once completely stable.
|
418
|
+
|
409
419
|
### <a name="capybara-webkit"></a>Capybara-webkit
|
410
420
|
|
411
421
|
Note: `capybara-webkit` depends on QtWebkit which went EOL quite some time ago. There has been an attempt to revive the project but `capybara-webkit` is not yet (AFAIK) compatible with the revived version of QtWebKit (could be a good OSS project for someone) and as such is still limited to an old version of QtWebKit. This means its support for modern JS and CSS is severely limited.
|
@@ -428,7 +438,7 @@ Capybara.javascript_driver = :webkit
|
|
428
438
|
|
429
439
|
### <a name="poltergeist"></a>Poltergeist
|
430
440
|
|
431
|
-
Note: `poltergeist` depends on PhantomJS for which active development ended quite some time ago (2.1.1). As such it is roughly equivalent to a 6-7 year old version of Safari, meaning lack of support for modern JS
|
441
|
+
Note: `poltergeist` depends on PhantomJS for which active development ended quite some time ago (2.1.1). As such it is roughly equivalent to a 6-7 year old version of Safari, meaning lack of support for modern JS and CSS. If any effort to update PhantomJS succeeds in the future this situation could change.
|
432
442
|
|
433
443
|
[Poltergeist](https://github.com/teampoltergeist/poltergeist) is another
|
434
444
|
headless driver which integrates Capybara with
|
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/lib/capybara/config.rb
CHANGED
@@ -7,12 +7,14 @@ module Capybara
|
|
7
7
|
class Config
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
OPTIONS = %i[app reuse_server threadsafe default_wait_time server
|
10
|
+
OPTIONS = %i[app reuse_server threadsafe default_wait_time server
|
11
|
+
default_driver javascript_driver allow_gumbo].freeze
|
11
12
|
|
12
13
|
attr_accessor :app
|
13
14
|
attr_reader :reuse_server, :threadsafe
|
14
15
|
attr_reader :session_options
|
15
16
|
attr_writer :default_driver, :javascript_driver
|
17
|
+
attr_accessor :allow_gumbo
|
16
18
|
|
17
19
|
SessionConfig::OPTIONS.each do |method|
|
18
20
|
def_delegators :session_options, method, "#{method}="
|
data/lib/capybara/driver/base.rb
CHANGED
@@ -15,11 +15,11 @@ class Capybara::Driver::Base
|
|
15
15
|
raise NotImplementedError
|
16
16
|
end
|
17
17
|
|
18
|
-
def find_xpath(query)
|
18
|
+
def find_xpath(query, **options)
|
19
19
|
raise NotImplementedError
|
20
20
|
end
|
21
21
|
|
22
|
-
def find_css(query)
|
22
|
+
def find_css(query, **options)
|
23
23
|
raise NotImplementedError
|
24
24
|
end
|
25
25
|
|
data/lib/capybara/driver/node.rb
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
module Capybara
|
4
4
|
module Driver
|
5
5
|
class Node
|
6
|
-
attr_reader :driver, :native
|
6
|
+
attr_reader :driver, :native, :initial_cache
|
7
7
|
|
8
|
-
def initialize(driver, native)
|
8
|
+
def initialize(driver, native, initial_cache = {})
|
9
9
|
@driver = driver
|
10
10
|
@native = native
|
11
|
+
@initial_cache = initial_cache
|
11
12
|
end
|
12
13
|
|
13
14
|
def all_text
|
@@ -68,6 +69,14 @@ module Capybara
|
|
68
69
|
raise NotImplementedError
|
69
70
|
end
|
70
71
|
|
72
|
+
def scroll_by(x, y)
|
73
|
+
raise NotImplementedError
|
74
|
+
end
|
75
|
+
|
76
|
+
def scroll_to(element, alignment, position = nil)
|
77
|
+
raise NotImplementedError
|
78
|
+
end
|
79
|
+
|
71
80
|
def tag_name
|
72
81
|
raise NotImplementedError
|
73
82
|
end
|
data/lib/capybara/minitest.rb
CHANGED
@@ -83,10 +83,10 @@ module Capybara
|
|
83
83
|
|
84
84
|
## Assert element has the provided CSS styles
|
85
85
|
#
|
86
|
-
# @!method
|
87
|
-
# see {Capybara::Node::Matchers#
|
86
|
+
# @!method assert_matches_style
|
87
|
+
# see {Capybara::Node::Matchers#assert_matches_style}
|
88
88
|
|
89
|
-
%w[selector no_selector
|
89
|
+
%w[selector no_selector matches_style
|
90
90
|
all_of_selectors none_of_selectors any_of_selectors
|
91
91
|
matches_selector not_matches_selector].each do |assertion_name|
|
92
92
|
class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
|
@@ -17,7 +17,7 @@ module Capybara
|
|
17
17
|
end + [%w[assert_all_of_selectors must_have_all_of_selectors],
|
18
18
|
%w[assert_none_of_selectors must_have_none_of_selectors],
|
19
19
|
%w[assert_any_of_selectors must_have_any_of_selectors],
|
20
|
-
%w[
|
20
|
+
%w[assert_matches_style must_match_style]] +
|
21
21
|
%w[selector xpath css].flat_map do |assertion|
|
22
22
|
[%W[assert_matches_#{assertion} must_match_#{assertion}],
|
23
23
|
%W[refute_matches_#{assertion} wont_match_#{assertion}]]
|
@@ -36,6 +36,13 @@ module Capybara
|
|
36
36
|
end
|
37
37
|
# rubocop:enable Style/MultilineBlockChain
|
38
38
|
|
39
|
+
##
|
40
|
+
# @deprecated
|
41
|
+
def must_have_style(*args, &block)
|
42
|
+
warn 'must_have_style is deprecated, please use must_match_style'
|
43
|
+
must_match_style(*args, &block)
|
44
|
+
end
|
45
|
+
|
39
46
|
##
|
40
47
|
# Expectation that there is xpath
|
41
48
|
#
|
@@ -169,8 +176,8 @@ module Capybara
|
|
169
176
|
##
|
170
177
|
# Expectation that element has style
|
171
178
|
#
|
172
|
-
# @!method
|
173
|
-
# see {Capybara::Node::Matchers#
|
179
|
+
# @!method must_match_style
|
180
|
+
# see {Capybara::Node::Matchers#assert_matches_style}
|
174
181
|
end
|
175
182
|
end
|
176
183
|
end
|
@@ -195,6 +195,8 @@ module Capybara
|
|
195
195
|
#
|
196
196
|
# @return [Capybara::Node::Element] The option element selected
|
197
197
|
def select(value = nil, from: nil, **options)
|
198
|
+
raise ArgumentError, 'The :from option does not take an element' if from.is_a? Capybara::Node::Element
|
199
|
+
|
198
200
|
el = from ? find_select_or_datalist_input(from, options) : self
|
199
201
|
|
200
202
|
if el.respond_to?(:tag_name) && (el.tag_name == 'input')
|
@@ -221,6 +223,8 @@ module Capybara
|
|
221
223
|
#
|
222
224
|
# @return [Capybara::Node::Element] The option element unselected
|
223
225
|
def unselect(value = nil, from: nil, **options)
|
226
|
+
raise ArgumentError, 'The :from option does not take an element' if from.is_a? Capybara::Node::Element
|
227
|
+
|
224
228
|
scope = from ? find(:select, from, options) : self
|
225
229
|
scope.find(:option, value, options).unselect_option
|
226
230
|
end
|
data/lib/capybara/node/base.rb
CHANGED
@@ -86,7 +86,7 @@ module Capybara
|
|
86
86
|
raise err unless driver.wait? && catch_error?(err, errors)
|
87
87
|
raise err if timer.expired?
|
88
88
|
|
89
|
-
sleep(0.
|
89
|
+
sleep(0.01)
|
90
90
|
reload if session_options.automatic_reload
|
91
91
|
retry
|
92
92
|
ensure
|
@@ -95,13 +95,21 @@ module Capybara
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# @api private
|
98
|
-
def find_css(css)
|
99
|
-
base.find_css
|
98
|
+
def find_css(css, **options)
|
99
|
+
if base.method(:find_css).arity != 1
|
100
|
+
base.find_css(css, **options)
|
101
|
+
else
|
102
|
+
base.find_css(css)
|
103
|
+
end
|
100
104
|
end
|
101
105
|
|
102
106
|
# @api private
|
103
|
-
def find_xpath(xpath)
|
104
|
-
base.find_xpath
|
107
|
+
def find_xpath(xpath, **options)
|
108
|
+
if base.method(:find_xpath).arity != 1
|
109
|
+
base.find_xpath(xpath, **options)
|
110
|
+
else
|
111
|
+
base.find_xpath(xpath)
|
112
|
+
end
|
105
113
|
end
|
106
114
|
|
107
115
|
# @api private
|
@@ -31,6 +31,18 @@ module Capybara
|
|
31
31
|
def title
|
32
32
|
session.driver.title
|
33
33
|
end
|
34
|
+
|
35
|
+
def execute_script(*args)
|
36
|
+
find(:xpath, '/html').execute_script(*args)
|
37
|
+
end
|
38
|
+
|
39
|
+
def evaluate_script(*args)
|
40
|
+
find(:xpath, '/html').evaluate_script(*args)
|
41
|
+
end
|
42
|
+
|
43
|
+
def scroll_to(*args)
|
44
|
+
find(:xpath, '//body').scroll_to(*args)
|
45
|
+
end
|
34
46
|
end
|
35
47
|
end
|
36
48
|
end
|
@@ -381,6 +381,38 @@ module Capybara
|
|
381
381
|
self
|
382
382
|
end
|
383
383
|
|
384
|
+
##
|
385
|
+
#
|
386
|
+
# Scroll the page or element
|
387
|
+
#
|
388
|
+
# Scroll the page or element to its top, bottom or middle
|
389
|
+
# @overload scroll_to(position, offset: [0,0])
|
390
|
+
# @param [:top, :bottom, :center, :current] position
|
391
|
+
# @param :offset
|
392
|
+
#
|
393
|
+
# Scroll the page or current element until the given element is aligned at the top, bottom, or center of it
|
394
|
+
# @overload scroll_to(element, align: :top)
|
395
|
+
# @param [Capybara::Node::Element] element The element to be scrolled into view
|
396
|
+
# @param [:top, :bottom, :center] :align Where to align the element being scrolled into view with relation to the current page/element if possible
|
397
|
+
#
|
398
|
+
# @overload scroll_to(x,y)
|
399
|
+
# @param [Integer] x Horizontal scroll offset
|
400
|
+
# @param [Integer] y Vertical scroll offset
|
401
|
+
#
|
402
|
+
# @return [Capybara::Node::Element] The element
|
403
|
+
def scroll_to(pos_or_el_or_x, y = nil, align: :top, offset: nil)
|
404
|
+
case pos_or_el_or_x
|
405
|
+
when Symbol
|
406
|
+
synchronize { base.scroll_to(nil, pos_or_el_or_x) } unless pos_or_el_or_x == :current
|
407
|
+
when Capybara::Node::Element
|
408
|
+
synchronize { base.scroll_to(pos_or_el_or_x.base, align) }
|
409
|
+
else
|
410
|
+
synchronize { base.scroll_to(nil, nil, [pos_or_el_or_x, y]) }
|
411
|
+
end
|
412
|
+
synchronize { base.scroll_by(*offset) } unless offset.nil?
|
413
|
+
self
|
414
|
+
end
|
415
|
+
|
384
416
|
##
|
385
417
|
#
|
386
418
|
# Execute the given JS in the context of the element not returning a result. This is useful for scripts that return
|
@@ -454,6 +486,11 @@ module Capybara
|
|
454
486
|
%(Obsolete #<Capybara::Node::Element>)
|
455
487
|
end
|
456
488
|
|
489
|
+
# @api private
|
490
|
+
def initial_cache
|
491
|
+
base.respond_to?(:initial_cache) ? base.initial_cache : {}
|
492
|
+
end
|
493
|
+
|
457
494
|
STYLE_SCRIPT = <<~JS
|
458
495
|
(function(){
|
459
496
|
var s = window.getComputedStyle(this);
|
@@ -36,6 +36,7 @@ module Capybara
|
|
36
36
|
# + Absence of a class can be checked by prefixing the class name with !
|
37
37
|
# + If you need to check for existence of a class name that starts with ! then prefix with !!
|
38
38
|
# + ```class:['a', '!b', '!!!c'] # limit to elements with class 'a' and '!c' but not class 'b'```
|
39
|
+
# @option options [String, Regexp, Hash] style Only find elements with matching style. String and Regexp will be checked against text of the elements `style` attribute, while a Hash will be compared against the elements full style
|
39
40
|
# @option options [Boolean] exact Control whether `is` expressions in the given XPath match exactly or partially
|
40
41
|
# @option options [Symbol] match The matching strategy to use.
|
41
42
|
#
|
@@ -56,13 +56,21 @@ module Capybara
|
|
56
56
|
#
|
57
57
|
# Checks if a an element has the specified CSS styles
|
58
58
|
#
|
59
|
-
# element.
|
59
|
+
# element.matches_style?( 'color' => 'rgb(0,0,255)', 'font-size' => /px/ )
|
60
60
|
#
|
61
61
|
# @param styles [Hash]
|
62
62
|
# @return [Boolean] If the styles match
|
63
63
|
#
|
64
|
+
def matches_style?(styles, **options)
|
65
|
+
make_predicate(options) { assert_matches_style(styles, options) }
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# @deprecated
|
70
|
+
#
|
64
71
|
def has_style?(styles, **options)
|
65
|
-
|
72
|
+
warn 'DEPRECATED: has_style? is deprecated, please use matches_style?'
|
73
|
+
matches_style?(styles, **options)
|
66
74
|
end
|
67
75
|
|
68
76
|
##
|
@@ -108,12 +116,12 @@ module Capybara
|
|
108
116
|
#
|
109
117
|
# Asserts that an element has the specified CSS styles
|
110
118
|
#
|
111
|
-
# element.
|
119
|
+
# element.assert_matches_style( 'color' => 'rgb(0,0,255)', 'font-size' => /px/ )
|
112
120
|
#
|
113
121
|
# @param styles [Hash]
|
114
122
|
# @raise [Capybara::ExpectationNotMet] If the element doesn't have the specified styles
|
115
123
|
#
|
116
|
-
def
|
124
|
+
def assert_matches_style(styles, **options)
|
117
125
|
query_args = _set_query_session_options(styles, options)
|
118
126
|
query = Capybara::Queries::StyleQuery.new(*query_args)
|
119
127
|
synchronize(query.wait) do
|
@@ -122,6 +130,13 @@ module Capybara
|
|
122
130
|
true
|
123
131
|
end
|
124
132
|
|
133
|
+
##
|
134
|
+
# @deprecated
|
135
|
+
def assert_style(styles, **options)
|
136
|
+
warn 'assert_style is deprecated, please use assert_matches_style instead'
|
137
|
+
assert_matches_style(styles, **options)
|
138
|
+
end
|
139
|
+
|
125
140
|
# Asserts that all of the provided selectors are present on the given page
|
126
141
|
# or descendants of the current node. If options are provided, the assertion
|
127
142
|
# will check that each locator is present with those options as well (other than :wait).
|
data/lib/capybara/node/simple.rb
CHANGED
@@ -164,12 +164,12 @@ module Capybara
|
|
164
164
|
end
|
165
165
|
|
166
166
|
# @api private
|
167
|
-
def find_css(css)
|
167
|
+
def find_css(css, **_options)
|
168
168
|
native.css(css)
|
169
169
|
end
|
170
170
|
|
171
171
|
# @api private
|
172
|
-
def find_xpath(xpath)
|
172
|
+
def find_xpath(xpath, **_options)
|
173
173
|
native.xpath(xpath)
|
174
174
|
end
|
175
175
|
|
@@ -178,6 +178,11 @@ module Capybara
|
|
178
178
|
Capybara.session_options
|
179
179
|
end
|
180
180
|
|
181
|
+
# @api private
|
182
|
+
def initial_cache
|
183
|
+
{}
|
184
|
+
end
|
185
|
+
|
181
186
|
private
|
182
187
|
|
183
188
|
def option_value(option)
|