Sha256: fc900dfd0e70d66fbe3ab760e1734d3d5e63c1e6589c3a08aa67df42d44602a5

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

module Watir  
  
  # Returned by {Container#link}.
  class Link < Element
    attr_ole :type
    attr_ole :href
    attr_ole :name

    # @deprecated Use "browser.link.imgs.length > 0" instead.
    def link_has_image
      Kernel.warn "Deprecated(Link#link_has_image) - use \"browser.link.imgs.length > 0\" instead."
      assert_exists
      @o.getElementsByTagName("IMG").length > 0
    end
    
    # @deprecated Use "browser.link.imgs.first.src rescue ''" instead.
    def src
      Kernel.warn "Deprecated(Link#link_has_image) - use \"browser.link.imgs.first.src rescue ''\" instead."
      assert_exists
      if @o.getElementsByTagName("IMG").length > 0
        return @o.getElementsByTagName("IMG")[0.to_s].src
      else
        return ""
      end
    end

    def to_s
      assert_exists
      r = string_creator
      r = r + link_string_creator
      return r.join("\n")
    end
    
    # @private
    def link_string_creator
      n = []
      n <<   "href:".ljust(TO_S_SIZE) + self.href
      n <<   "inner text:".ljust(TO_S_SIZE) + self.text
      n <<   "img src:".ljust(TO_S_SIZE) + self.src if self.link_has_image
      return n
    end
    
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
watir-classic-4.3.0 lib/watir-classic/link.rb
watir-classic-4.2.0 lib/watir-classic/link.rb
watir-classic-4.1.0 lib/watir-classic/link.rb
watir-classic-4.0.1 lib/watir-classic/link.rb
watir-classic-4.0.0 lib/watir-classic/link.rb
watir-classic-3.7.0 lib/watir-classic/link.rb
watir-classic-3.6.0 lib/watir-classic/link.rb
watir-classic-3.5.0 lib/watir-classic/link.rb
watir-classic-3.4.0 lib/watir-classic/link.rb