Class: Howitzer::Meta::Iframe

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

Overview

This class represents iframe 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) ⇒ Iframe

Creates new meta iframe element with meta information and utility actions

Parameters:

  • name (String)

    name of the iframe

  • context (Howitzer::Web::Page)

    page which has this iframe


12
13
14
15
# File 'lib/howitzer/meta/iframe.rb', line 12

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/iframe.rb', line 5

def context
  @context
end

#nameObject (readonly)

Returns the value of attribute name.


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

def name
  @name
end

Instance Method Details

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

Finds iframe on the page and returns as a capybara element

Parameters:

  • wait (Integer) (defaults to: 0)

    wait time for element search

Returns:

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

26
27
28
29
30
# File 'lib/howitzer/meta/iframe.rb', line 26

def capybara_element(wait: 0)
  context.capybara_context.find("iframe[src='#{site_value}']", match: :first, wait: wait)
rescue Capybara::ElementNotFound
  nil
end

#capybara_elementsArray

Finds all instances of iframe on the page and returns them as array of capybara elements

Returns:

  • (Array)

19
20
21
# File 'lib/howitzer/meta/iframe.rb', line 19

def capybara_elements
  context.capybara_context.all("iframe[src='#{site_value}']")
end

#site_valueString

Returns url value for iframe

Returns:

  • (String)

34
35
36
37
38
# File 'lib/howitzer/meta/iframe.rb', line 34

def site_value
  return @site_value if @site_value.present?

  context.send("#{name}_iframe") { |frame| @site_value = frame.class.send(:site_value) }
end