<commit_before>module Capybara
  module Searchable
    def find(*args)
      all(*args).first
    end

    def find_field(locator)
      find(XPath.field(locator))
    end
    alias_method :field_labeled, :find_field

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

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

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

    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]
        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
<commit_msg>Set correct selector type for built in finds<commit_after>module Capybara
  module Searchable
    def find(*args)
      all(*args).first
    end

    def find_field(locator)
      find(:xpath, XPath.field(locator))
    end
    alias_method :field_labeled, :find_field

    def find_link(locator)
      find(:xpath, XPath.link(locator))
    end

    def find_button(locator)
      find(:xpath, XPath.button(locator))
    end

    def find_by_id(id)
      find(:css, "##{id}")
    end

    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]
        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

{'fraction_non_alphanumeric': 0.10962301587301587, 'fraction_numerical': 0.000992063492063492, 'mean_word_length': 2.520069808027923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1176237', 'n_tokens_mistral': 680, 'n_tokens_neox': 662, 'n_words': 151}