gems/ruby/2.2.0/gems/watir-webdriver-0.7.0/lib/watir-webdriver/elements/element.rb
#
# Cast this Element instance to a more specific subtype.
#
# @example
#   browser.element(:xpath => "//input[@type='submit']").to_subtype
#   #=> #<Watir::Button>
#
Cast this Element instance to a more specific subtype.
Cast this Element instance to a more specific subtype .
def to_subtype
      elem = wd()
      tag_name = elem.tag_name.downcase
      klass = nil
      if tag_name == "input"
        klass = case elem.attribute(:type)
          when *Button::VALID_TYPES
            Button
          when 'checkbox'
            CheckBox
          when 'radio'
            Radio
          when 'file'
            FileField
          else
            TextField
          end
      else
        klass = Watir.element_class_for(tag_name)
      end
      klass.new(@parent, :element => elem)
    end
def to_subtype elem = wd ( ) tag_name = elem . tag_name . downcase klass = nil if tag_name == "input" klass = case elem . attribute ( :type ) when * Button :: VALID_TYPES Button when 'checkbox' CheckBox when 'radio' Radio when 'file' FileField else TextField end else klass = Watir . element_class_for ( tag_name ) end klass . new ( @parent , :element => elem ) end
Cast this Element instance to a more specific subtype.
Cast this Element instance to a more specific subtype .
example
browser.element(:xpath => "//input[@type='submit']").to_subtype #=> #
browser . element ( : xpath = > " // input [ @type = ' submit ' ] " ) . to_subtype # = > #