I have this html code:
<tbody>
<tr>
<td class=message>
<div class=div10l>Fill In All Fields With<IMG style="CURSOR: hand" border=0 alt="Not Null" src="../img/re.gif">.</div>
<span style="COLOR: red">
<a href="../main/Error.jsp" target=_blank>
<span style="COLOR: red">Exception: ERROR: duplicate key value</span>
</a>
<br>
</span>
<br>
</td>
</tr>
</tbody>
If there is error on the page I get the message Exception: ERROR: duplicate key value, which is the link for a detailed explanation. How can I click on this text using only part of text – Exception?
I tried ie1.span(:text => /Exception: ERROR:/).click, but the link isn’t opened.
If I try ie1.link(:href, “../main/Error.jsp”).click – I get the following:
can't find the object -
E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:66:in `assert_exists': Unable to locate element, using {:tag_name=>["a"], :href=>"../main/Error.jsp"} (Watir::Exception::UnknownObjectException)
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:414:in `perform_action'
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:269:in `click!'
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:211:in `click'
from file1.rb:53:in `<main>'
Try this:
This is clicking the link based on its text. The text of the span within the anchor tag counts as the anchor tags text.