class Howitzer::Meta::Element

This class represents element entity within howitzer meta information interface

Attributes

context[R]
name[R]

Public Class Methods

new(name, context) click to toggle source

Creates new meta element with meta information and utility actions @param name [String] name of the element @param context [Howitzer::Web::Page] page element belongs to

# File lib/howitzer/meta/element.rb, line 11
def initialize(name, context)
  @name = name
  @context = context
end

Public Instance Methods

capybara_element(*args, wait: 0, **options) click to toggle source

Finds element on the page and returns as a capybara element @param args [Array] arguments for elements described with lambda locators @param options [Hash] original Capybara options. For details, see ‘Capybara::Node::Finders#all` @param wait [Integer] wait time for element search @return [Capybara::Node::Element, nil]

# File lib/howitzer/meta/element.rb, line 33
def capybara_element(*args, wait: 0, **options)
  context.send("#{name}_element", *args, **options.merge(match: :first, wait: wait))
rescue Capybara::ElementNotFound
  nil
end
capybara_elements(*args, **options) click to toggle source

Finds all instances of element on the page and returns them as array of capybara elements @param args [Array] arguments for elements described with lambda locators @param options [Hash] original Capybara options. For details, see ‘Capybara::Node::Finders#all` @return [Array]

# File lib/howitzer/meta/element.rb, line 20
def capybara_elements(*args, **options)
  if options.present?
    context.send("#{name}_elements", *args, **options)
  else
    context.send("#{name}_elements", *args)
  end
end