class FireWatir::NonControlElement

Base class containing items that are common between the span, div, label, p and pre classes.

Attributes

element_name[RW]

Public Class Methods

inherited(subclass) click to toggle source
# File lib/firewatir/elements/non_control_element.rb, line 5
def self.inherited subclass
  class_name = Watir::Util.demodulize(subclass.to_s)
  method_name = Watir::Util.underscore(class_name)
  FireWatir::Container.module_eval "def #{method_name}(how, what=nil)
  locate if respond_to?(:locate)
  return #{class_name}.new(self, how, what); end"
end
new(container, how, what) click to toggle source
  • how - Attribute to identify the element.

  • what - Value of that attribute.

# File lib/firewatir/elements/non_control_element.rb, line 33
def initialize(container, how, what)
  #@element = Element.new(nil)

  @how = how
  @what = what
  @container = container
  @o = nil
end

Public Instance Methods

locate() click to toggle source

Description:

Locate the element on the page. Element can be a span, div, label, p or pre HTML tag.
# File lib/firewatir/elements/non_control_element.rb, line 19
def locate
  case @how
  when :jssh_name
    @element_name = @what
  when :xpath
    @element_name = element_by_xpath(@container, @what)
  else
    @element_name = locate_tagged_element(self.class::TAG, @how, @what)
  end
  @o = self
end
to_s(attributes = nil) click to toggle source

Returns a string of properties of the object.

# File lib/firewatir/elements/non_control_element.rb, line 42
def to_s(attributes = nil)
  assert_exists
  hash_properties = {"text"=>"innerHTML"}
  hash_properties.update(attributes) if attributes != nil
  r = super(hash_properties)
  #r = string_creator

  #r += span_div_string_creator

  return r.join("\n")
end