Sha256: 736fb4383b6404e82ad1a940f2dcf9b8cd3ed46a1f9c60e027dabd35cbe11887

Contents?: true

Size: 1.54 KB

Versions: 10

Compression:

Stored size: 1.54 KB

Contents

module FireWatir

  # Base class containing items that are common between the span, div, label, p and pre classes.
  class NonControlElement < Element
    def self.inherited subclass
      class_name = subclass.to_s.demodulize
      method_name = class_name.underscore
      FireWatir::Container.module_eval "def #{method_name}(how, what=nil)
      locate if respond_to?(:locate)
      return #{class_name}.new(self, how, what); end"
    end

    attr_accessor :element_name

    #
    # Description:
    #   Locate the element on the page. Element can be a span, div, label, p or pre HTML tag.
    #
    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

    #   - how - Attribute to identify the element.
    #   - what - Value of that attribute.
    def initialize(container, how, what)
      #@element = Element.new(nil)
      @how = how
      @what = what
      @container = container
      @o = nil
    end

    # Returns a string of properties of the object.
    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

  end # NonControlElement
end # FireWatir

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
firewatir-1.8.0 lib/firewatir/elements/non_control_element.rb
firewatir-1.8.0.rc1 lib/firewatir/elements/non_control_element.rb
firewatir-1.7.1 lib/firewatir/elements/non_control_element.rb
firewatir-1.7.0 lib/firewatir/elements/non_control_element.rb
firewatir-1.7.0.rc1 lib/firewatir/elements/non_control_element.rb
firewatir-1.6.7 lib/firewatir/elements/non_control_element.rb
firewatir-1.6.7.rc1 lib/firewatir/elements/non_control_element.rb
firewatir-1.6.6 lib/firewatir/elements/non_control_element.rb
firewatir-1.6.6.rc2 lib/firewatir/elements/non_control_element.rb
firewatir-1.6.6.rc1 lib/firewatir/elements/non_control_element.rb