Reputation: 1
I am new to ruby/watir and am getting an error when trying to click on a link. The error is:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-4.0.1/lib/watir-classic/elemen
t.rb:328:in `assert_exists': Unable to locate element, using {:tag_name=>["a"],
:id=>"My Link"} (Watir::Exception::UnknownObjectException)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-4.0.1/lib/watir-c
lassic/element.rb:474:in `perform_action'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-4.0.1/lib/watir-c
lassic/element.rb:354:in `click!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-4.0.1/lib/watir-c
lassic/element.rb:157:in `click'
from Login.rb:22:in `<main>'
The link that I am trying to click looks like this:
<TD><DIV id=div style="DISPLAY: inline"><A id=Hyperlink href="javascript:RunFullScreen('myURL')">My Link</A></DIV>
Also, I tried to write out all links on the page using 'puts', but nothing was written out when the script finished I used this code to write out the links (not sure if this is correct or not):
browser.links.each {|link| puts link.attribute_value("text") if link.visible?}
Upvotes: 0
Views: 316
Reputation: 16507
The error says tat you tried to find an object with the following properties: {:tag_name=>["a"], :id=>"My Link"}
, but you have show us HTML code with A id=Hyperlink
. So to find out that HTML you need to specify properly its attributes:
@b.element :tag_name => 'a', :id => 'Hyperlink'
or
@b.a :id => 'Hyperlink'
Upvotes: 1