我有这个HTML代码:
<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>
如果页面上有错误,我会收到消息Exception:ERROR:重复键值,这是详细说明的链接。如何仅使用部分文本单击此文本 - 例外?
我尝试了ie1.span(:text =&gt; / Exception:ERROR:/)。点击,但链接未打开。
如果我尝试ie1.link(:href,“../ main / Error.jsp”)。点击 - 我得到以下内容:
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>'
答案 0 :(得分:2)
试试这个:
browser.link(:text => /Exception: ERROR:/).click
这是根据文本点击链接。锚标记中跨度的文本计为锚标记文本。