class PageMagic::Element::Query

class Query - executes query on capybara driver

Constants

DEFAULT_DECORATOR

Attributes

options[R]
selector_args[R]

Public Class Methods

new(*selector_args, options: {}) click to toggle source
# File lib/page_magic/element/query.rb, line 14
def initialize(*selector_args, options: {})
  @selector_args = selector_args
  @options = options
end

Public Instance Methods

==(other) click to toggle source
# File lib/page_magic/element/query.rb, line 31
def ==(other)
  other.respond_to?(:selector_args) && selector_args == other.selector_args &&
    other.respond_to?(:options) && options == other.options
end
execute(capybara_element, &block) click to toggle source

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

# File lib/page_magic/element/query.rb, line 25
def execute(capybara_element, &block)
  find(capybara_element, &(block || DEFAULT_DECORATOR))
rescue Capybara::ElementNotFound => e
  NotFound.new(e)
end