Class: Webrat::Element

Inherits:
Object show all
Defined in:
lib/webrat/core/elements/element.rb

Overview

:nodoc:

Direct Known Subclasses

Area, Field, Form, Label, Link, SelectOption

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, element) ⇒ Element

Returns a new instance of Element.



18
19
20
21
# File 'lib/webrat/core/elements/element.rb', line 18

def initialize(session, element)
  @session  = session
  @element  = element
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



16
17
18
# File 'lib/webrat/core/elements/element.rb', line 16

def element
  @element
end

Class Method Details

.load(session, element) ⇒ Object



11
12
13
14
# File 'lib/webrat/core/elements/element.rb', line 11

def self.load(session, element)
  return nil if element.nil?
  session.elements[Webrat::XML.xpath_to(element)] ||= self.new(session, element)
end

.load_all(session, dom) ⇒ Object



5
6
7
8
9
# File 'lib/webrat/core/elements/element.rb', line 5

def self.load_all(session, dom)
  Webrat::XML.xpath_search(dom, xpath_search).map do |element| 
    load(session, element)
  end
end

Instance Method Details

#inspectObject



27
28
29
# File 'lib/webrat/core/elements/element.rb', line 27

def inspect
  "#<#{self.class} @element=#{element.inspect}>"
end

#pathObject



23
24
25
# File 'lib/webrat/core/elements/element.rb', line 23

def path
  Webrat::XML.xpath_to(@element)
end