lib/celerity/elements/link.rb in celerity-0.0.4 vs lib/celerity/elements/link.rb in celerity-0.0.6

- old
+ new

@@ -1,18 +1,30 @@ -module Celerity - class Link < Element - - TAGS = [ Identifier.new('a') ] - ATTRIBUTES = BASE_ATTRIBUTES | [:charset, :type, :name, :href, :hreflang, - :target, :rel, :rev, :accesskey, :shape, - :coords, :tabindex, :onfocus, :onblur] - DEFAULT_HOW = :href - - # clicks the link - def click - assert_exists - @container.update_page @object.click - end - - end - -end +module Celerity + class Link < Element + include ClickableElement + + TAGS = [ Identifier.new('a') ] + ATTRIBUTES = BASE_ATTRIBUTES | [:charset, :type, :name, :href, :hreflang, + :target, :rel, :rev, :accesskey, :shape, + :coords, :tabindex, :onfocus, :onblur] + DEFAULT_HOW = :href + + # + # Returns the absolute URL for this link (Celerity-specific) + # + # (Watir/IE does this for href(), but we don't want that.) + # + + def absolute_url + assert_exists + href = @object.getAttributeValue('href') + + unless href.empty? || URI.parse(href).absolute? + href = URI.join(browser.url, href).to_s + end + + href + end + + + end # Link +end # Celerity \ No newline at end of file