Permalink
Browse files

Add support for locating Link by a :name. Fixes #42.

  • Loading branch information...
1 parent 281a0a7 commit bd128a9609729d2f2d87c85b071045445d7669ef @jarmo jarmo committed Oct 21, 2012
Showing with 16 additions and 2 deletions.
  1. +2 −2 lib/watir-classic/link.rb
  2. +14 −0 spec/link_spec.rb
@@ -7,12 +7,12 @@ module Watir
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
def link_has_image
assert_exists
- return true if @o.getElementsByTagName("IMG").length > 0
- return false
+ @o.getElementsByTagName("IMG").length > 0
end
# this method returns the src of an image, if an image is used as part of the link
View
@@ -0,0 +1,14 @@
+# encoding: utf-8
+require File.expand_path("watirspec/spec_helper", File.dirname(__FILE__))
+
+describe "Link" do
+ before do
+ browser.goto(WatirSpec.url_for("non_control_elements.html"))
+ end
+
+ context "#exists?" do
+ it "finds link by a name" do
+ browser.a(:name => "bad_attribute").should exist
+ end
+ end
+end

0 comments on commit bd128a9

Please sign in to comment.