Class: Howitzer::Meta::Element

Inherits:
Object
  • Object
show all
Includes:
Actions
Defined in:
lib/howitzer/meta/element.rb

Overview

This class represents element entity within howitzer meta information interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Actions

#highlight, #xpath

Constructor Details

#initialize(name, context) ⇒ Element

Creates new meta element with meta information and utility actions

Parameters:

  • name (String)

    name of the element

  • context (Howitzer::Web::Page)

    page element belongs to



11
12
13
14
# File 'lib/howitzer/meta/element.rb', line 11

def initialize(name, context)
  @name = name
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/howitzer/meta/element.rb', line 5

def context
  @context
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/howitzer/meta/element.rb', line 5

def name
  @name
end

Instance Method Details

#capybara_element(*args, wait: 0) ⇒ Capybara::Node::Element?

Finds element on the page and returns as a capybara element inline options for element/s as a hash

Parameters:

  • args (Array)

    arguments for elements described with lambda locators and

  • wait (Integer) (defaults to: 0)

    wait time for element search

Returns:

  • (Capybara::Node::Element, nil)


29
30
31
32
33
34
35
# File 'lib/howitzer/meta/element.rb', line 29

def capybara_element(*args, wait: 0)
  args << { match: :first, wait: wait }
  args = convert_args(args)
  context.send("#{name}_element", *args)
rescue Capybara::ElementNotFound
  nil
end

#capybara_elements(*args) ⇒ Array

Finds all instances of element on the page and returns them as array of capybara elements inline options for element/s as a hash

Parameters:

  • args (Array)

    arguments for elements described with lambda locators and

Returns:

  • (Array)


20
21
22
# File 'lib/howitzer/meta/element.rb', line 20

def capybara_elements(*args)
  context.send("#{name}_elements", *args)
end