Module: Capybara::Searchable

Included in:
Node, Session
Defined in:
lib/capybara/searchable.rb

Instance Method Summary collapse

Instance Method Details

#all(locator, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/capybara/searchable.rb', line 24

def all(locator, options = {})
  results = all_unfiltered(locator)

  if options[:text]
    results = results.select { |n| n.text.match(options[:text]) }
  end

  if options[:visible] == true
    results.reject! { |n| !n.visible? }
  end

  results
end

#find(locator, options = {}) ⇒ Object



3
4
5
# File 'lib/capybara/searchable.rb', line 3

def find(locator, options = {})
  all(locator, options).first
end

#find_button(locator) ⇒ Object



16
17
18
# File 'lib/capybara/searchable.rb', line 16

def find_button(locator)
  find(XPath.button(locator))
end

#find_by_id(id) ⇒ Object



20
21
22
# File 'lib/capybara/searchable.rb', line 20

def find_by_id(id)
  find(Xpath.for_css("##{id}"))
end

#find_field(locator) ⇒ Object Also known as: field_labeled



7
8
9
# File 'lib/capybara/searchable.rb', line 7

def find_field(locator)
  find(XPath.field(locator))
end


12
13
14
# File 'lib/capybara/searchable.rb', line 12

def find_link(locator)
  find(XPath.link(locator))
end