这是我正在使用的 Watir 代码:
require 'watir-classic'
browser = Watir::IE.new
browser.link(:class, "Wizardbutton").exists?
这是包含我要检查是否存在的链接的页面 HTML 的一部分。
<tr>
<td align="left" style="vertical-align: top;">
<a class="Wizardbutton"href="javascript:parent.showPopup('/web/wizard.html');window.focus();">
<span>Add new Team</span>
</a>
</td>
</tr>
我得到的错误是:
Watir::Exception::UnknownObjectException: Unable to locate element, using {:tag_name=>["a"], :class=>"Wizardbutton"}
为什么我在 HTML 源代码中可以清楚地看到链接元素不存在的错误?我已经成功点击了页面上的其他链接,但由于某种原因我看不到这个。嵌入的跨度标签是否搞砸了?我也尝试使用 href 进行选择,但也没有用。任何见解将不胜感激!