module Capybara::Selenium::Find

def gather_hints(elements, uses_visibility:, styles:, position:)

def gather_hints(elements, uses_visibility:, styles:, position:)
  hints_js, functions = build_hints_js(uses_visibility, styles, position)
  return [] unless functions.any?
  (es_context.execute_script(hints_js, elements) || []).map! do |results|
    hint = {}
    hint[:style] = results.pop if functions.include?(:style_func)
    hint[:position] = results.pop if functions.include?(:position_func)
    hint[:visible] = results.pop if functions.include?(:vis_func)
    hint
  end
rescue ::Selenium::WebDriver::Error::StaleElementReferenceError,
       ::Capybara::NotSupportedByDriverError
  # warn 'Unexpected Stale Element Error - skipping optimization'
  []
end