Sha256: 6272ed4e606fb01087d74695e76c666ea5d8df9856fa43b717a53a7b81b30e7c
Contents?: true
Size: 1.21 KB
Versions: 12
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require_relative 'query/multiple_results' require_relative 'query/single_result' require_relative 'query/prefetched_result' module PageMagic class Element # class Query - executes query on capybara driver class Query attr_reader :selector_args, :options DEFAULT_DECORATOR = proc { |arg| arg }.freeze def initialize(*selector_args, options: {}) @selector_args = selector_args @options = options end # TODO: - test for decoration? # Run query against the scope of the given element # The supplied block will be used to decorate the results # @param [Capybara::Node::Element] capybara_element the element to be searched within # @return [Array<Capybara::Node::Element>] the results # @return [NullElement] when the element is not found def execute(capybara_element, &block) find(capybara_element, &(block || DEFAULT_DECORATOR)) rescue Capybara::ElementNotFound => e NotFound.new(e) end def ==(other) other.respond_to?(:selector_args) && selector_args == other.selector_args && other.respond_to?(:options) && options == other.options end end end end
Version data entries
12 entries across 12 versions & 1 rubygems