Module: Capybara::Node::Matchers

Included in:
Capybara::Node
Defined in:
lib/capybara/node/matchers.rb

Instance Method Summary collapse

Instance Method Details

#has_button?(locator) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/capybara/node/matchers.rb', line 56

def has_button?(locator)
  has_xpath?(XPath.button(locator))
end

#has_checked_field?(locator) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/capybara/node/matchers.rb', line 72

def has_checked_field?(locator)
  has_xpath?(XPath.field(locator, :checked => true))
end

#has_content?(content) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/capybara/node/matchers.rb', line 40

def has_content?(content)
  has_xpath?(XPath.content(content))
end

#has_css?(path, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/capybara/node/matchers.rb', line 32

def has_css?(path, options={})
  has_xpath?(XPath.from_css(path), options)
end

#has_field?(locator, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/capybara/node/matchers.rb', line 64

def has_field?(locator, options={})
  has_xpath?(XPath.field(locator, options))
end

#has_link?(locator) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/capybara/node/matchers.rb', line 48

def has_link?(locator)
  has_xpath?(XPath.link(locator))
end

#has_no_button?(locator) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/capybara/node/matchers.rb', line 60

def has_no_button?(locator)
  has_no_xpath?(XPath.button(locator))
end

#has_no_content?(content) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/capybara/node/matchers.rb', line 44

def has_no_content?(content)
  has_no_xpath?(XPath.content(content))
end

#has_no_css?(path, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/capybara/node/matchers.rb', line 36

def has_no_css?(path, options={})
  has_no_xpath?(XPath.from_css(path), options)
end

#has_no_field?(locator, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/capybara/node/matchers.rb', line 68

def has_no_field?(locator, options={})
  has_no_xpath?(XPath.field(locator, options))
end

#has_no_link?(locator) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/capybara/node/matchers.rb', line 52

def has_no_link?(locator)
  has_no_xpath?(XPath.link(locator))
end

#has_no_select?(locator, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/capybara/node/matchers.rb', line 84

def has_no_select?(locator, options={})
  has_no_xpath?(XPath.select(locator, options))
end

#has_no_table?(locator, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/capybara/node/matchers.rb', line 92

def has_no_table?(locator, options={})
  has_no_xpath?(XPath.table(locator, options))
end

#has_no_xpath?(path, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/capybara/node/matchers.rb', line 18

def has_no_xpath?(path, options={})
  wait_conditionally_until do
    results = all(:xpath, path, options)

    if options[:count]
      results.size != options[:count]
    else
      results.empty?
    end
  end
rescue Capybara::TimeoutError
  return false
end

#has_select?(locator, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/capybara/node/matchers.rb', line 80

def has_select?(locator, options={})
  has_xpath?(XPath.select(locator, options))
end

#has_table?(locator, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/capybara/node/matchers.rb', line 88

def has_table?(locator, options={})
  has_xpath?(XPath.table(locator, options))
end

#has_unchecked_field?(locator) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/capybara/node/matchers.rb', line 76

def has_unchecked_field?(locator)
  has_xpath?(XPath.field(locator, :unchecked => true))
end

#has_xpath?(path, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/capybara/node/matchers.rb', line 4

def has_xpath?(path, options={})
  wait_conditionally_until do
    results = all(:xpath, path, options)

    if options[:count]
      results.size == options[:count]
    else
      results.size > 0
    end
  end
rescue Capybara::TimeoutError
  return false
end