Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the options to Capybara's have_selector?

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
like image 519
Ahmed Khedr Avatar asked May 30 '14 18:05

Ahmed Khedr


Video Answer


1 Answers

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
like image 83
Dave Schweisguth Avatar answered Sep 18 '22 15:09

Dave Schweisguth