问题
I got this error in RSpec. Are there any docs for have_selector
that explain each key in the options hash and what exactly it does?
invalid keys :content, should be one of :text, :visible, :between, :count, :maximum, :minimum, :exact, :match, :wait
回答1:
capybara provides this method to rspec. capybara's docs don't make it easy to find the answer to your question, so let's follow the source:
have_selector
is in Capybara::RSpecMatchers
. It delegates to the nested class HaveSelector
, which delegates to the method assert_selector
.
assert_selector
is in Capybara::Node::Matchers
. (So is a method has_selector?
, although that's not what rspec calls.) assert_selector's rdoc documents the :count
option. It also says "It also accepts all options that Finders#all accepts, such as :text and :visible." Clicking through to Finders#all finally gets us to the documentation of all the options:
Options Hash (options):
- text (String, Regexp) — Only find elements which contain this text or match this regexp
- visible (Boolean) — Only find elements that are visible on the page. Setting this to false finds - invisible and visible elements.
- count (Integer) — Exact number of matches that are expected to be found
- maximum (Integer) — Maximum number of matches that are expected to be found
- minimum (Integer) — Minimum number of matches that are expected to be found
- between (Range) — Number of matches found must be within the given range
- exact (Boolean) — Control whether
is
expressions in the given XPath match exactly or partially
来源:https://stackoverflow.com/questions/23961636/what-are-the-options-to-capybaras-have-selector