水豚的have_selector有哪些选项? [英] What are the options to Capybara's have_selector?
问题描述
我在RSpec中遇到此错误。 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
推荐答案
capybara为rspec提供了此方法。 capybara的文档很难找到问题的答案,所以让我们关注源代码:
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
在 Capybara :: RSpecMatchers
中。它委托给嵌套类 HaveSelector
,后者将委托给方法 assert_selector
。
have_selector
is in Capybara::RSpecMatchers
. It delegates to the nested class HaveSelector
, which delegates to the method assert_selector
.
assert_selector
在 Capybara :: Node :: Matchers
中。 (所以方法 has_selector是吗?
,尽管那不是rspec调用的。) assert_selector
的rdoc 记录了:count
选项。它还说:它也接受Finders#all接受的所有选项,例如:text和:visible。点击进入 Finders#all
最终使我们了解所有选项的文档:
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:
选项哈希(选项):
- 文本(字符串,正则表达式)—仅查找包含该文本或与该正则表达式匹配的元素
- 可见(布尔值)—仅查找页面上可见的元素。将其设置为错误的查找-不可见和可见的元素。
- count(整数)-预期将找到的精确匹配项
- 最大值(整数)-期望找到的最大匹配数
- 最小值(整数)-期望找到的最小匹配数
- 之间(范围)-找到的匹配数必须在给定范围内
- 精确(布尔值)-控制是否在
是
表达式中给定XPath完全或部分匹配
- 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
这篇关于水豚的have_selector有哪些选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!