Capybara::Searchable

Public Instance Methods

all(*args) click to toggle source
# File lib/capybara/searchable.rb, line 24
def all(*args)
  options = if args.last.is_a?(Hash) then args.pop else {} end
  if args[1].nil?
    kind, locator = Capybara.default_selector, args.first
  else
    kind, locator = args
  end
  locator = XPath.from_css(locator) if kind == :css

  results = all_unfiltered(locator)

  if options[:text]
    options[:text] = Regexp.escape(options[:text]) unless options[:text].kind_of?(Regexp)
    results = results.select { |n| n.text.match(options[:text]) }
  end

  if options[:visible] or Capybara.ignore_hidden_elements
    results = results.select { |n| n.visible? }
  end

  results
end
field_labeled(locator) click to toggle source
Alias for: find_field
find(*args) click to toggle source
# File lib/capybara/searchable.rb, line 3
def find(*args)
  all(*args).first
end
find_button(locator) click to toggle source
# File lib/capybara/searchable.rb, line 16
def find_button(locator)
  find(:xpath, XPath.button(locator))
end
find_by_id(id) click to toggle source
# File lib/capybara/searchable.rb, line 20
def find_by_id(id)
  find(:css, "##{id}")
end
find_field(locator) click to toggle source
# File lib/capybara/searchable.rb, line 7
def find_field(locator)
  find(:xpath, XPath.field(locator))
end
Also aliased as: field_labeled

[Validate]

Generated with the Darkfish Rdoc Generator 2.