lib/watir-classic/link.rb in watir-classic-3.3.0 vs lib/watir-classic/link.rb in watir-classic-3.4.0
- old
+ new
@@ -1,46 +1,45 @@
module Watir
- # This class is the means of accessing a link on a page
- # Normally a user would not need to create this object as it is returned by the Watir::Container#link method
- # many of the methods available to this object are inherited from the Element class
- #
+ # Returned by {Container#link}.
class Link < Element
attr_ole :type
attr_ole :href
attr_ole :name
- # if an image is used as part of the link, this will return true
+ # @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
- # this method returns the src of an image, if an image is used as part of the link
- def src # BUG?
+ # @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
- # returns a textual description of the link
- def to_s
- assert_exists
- r = string_creator
- r = r + link_string_creator
- return r.join("\n")
- end
-
end
end