What are the options to Capybara's have_selector?

孤人 提交于 2019-12-22 03:43:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!