24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# 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
|