def element(name, tag=:element, identifier={ :index => 0 }, &block)
      #
      # sets tag as element if not defined
      #
      if tag.is_a?(Hash)
        identifier = tag
        tag        = :element
      end

      standard_methods(name, identifier, 'element_for', &block)

      define_method("#{name}") do
        element = self.send("#{name}_element")

        %w(Button TextField Radio Hidden CheckBox FileField).each do |klass|
          next unless element.element.class.to_s  == "Watir::#{klass}"
          self.class.send(klass.gsub(/(.)([A-Z])/,'\1_\2').downcase, name, identifier, &block)
          return self.send name
        end
        element.text
      end
      define_method("#{name}_element") do
        return call_block(&block) if block_given?
        platform.element_for(tag, identifier.clone)
      end
      define_method("#{name}?") do
        self.send("#{name}_element").exists?
      end
      define_method("#{name}=") do |value|
        element = self.send("#{name}_element")

        klass = case element.element
                when Watir::TextField
                  'text_field'
                when Watir::TextArea
                  'text_area'
                when Watir::Select
                  'select_list'
                when Watir::FileField
                  'file_field'
                else
                  raise "Can not set a #{element.element} element with #="
                end
        self.class.send(klass, name, identifier, &block)
        self.send("#{name}=", value)
      end
    end
def element(name, tag=:element, identifier={ :index => 0 }, &block)
      #
      # sets tag as element if not defined
      #
      if tag.is_a?(Hash)
        identifier = tag
        tag        = :element
      end

      standard_methods(name, identifier, 'element_for', &block)

      define_method("#{name}") do
        element = self.send("#{name}_element")

        %w(Button TextField Radio Hidden CheckBox FileField).each do |klass|
          next unless element.element.class.to_s  == "Watir::#{klass}"
          self.class.send(klass.gsub(/(.)([A-Z])/,'\1_\2').downcase, name, identifier, &block)
          return self.send name
        end
        element.text
      end
      define_method("#{name}_element") do
        return call_block(&block) if block_given?
        platform.element_for(tag, identifier.clone)
      end
      define_method("#{name}?") do
        self.send("#{name}_element").exists?
      end
      define_method("#{name}=") do |value|
        element = self.send("#{name}_element")

        klass = case element.element
                when Watir::TextField
                  'text_field'
                when Watir::TextArea
                  'text_area'
                when Watir::Select
                  'select_list'
                when Watir::FileField
                  'file_field'
                else
                  raise "Can not set a #{element.element} element with #="
                end
        self.class.send(klass, name, identifier, &block)
        self.send("#{name}=", value)
      end
    end
adds three methods - one to retrieve the text of an element, another
 to retrieve an element, and another to check the element's existence.

 @example
   element(:title, :header, :id => 'title')
   # will generate 'title', 'title_element', and 'title?' methods

 @param [Symbol] the name used for the generated methods
 @param [Symbol] the name of the tag for the element
 @param [Hash] identifier how we find an element.
 @param optional block to be invoked when element method is called