【发布时间】:2012-04-25 13:43:40
【问题描述】:
我正在尝试使用 Watir 完成重复性任务,但遇到了困难,需要您的帮助。我有下面的按钮代码:
<button class="ppm_button " onclick="submitForm('page','more=1');" type="button">
<img border="0" align="absmiddle" title="Add and Select More" alt="Add and Select More" style="width: 11px; height: 8px; background: url("ui/uitk/images/nde.png") no-repeat scroll 0px 0px transparent;" src="ui/uitk/images/s.gif" >
Add and Select More
</button>
我尝试使用 firebug 获取 xpath 并使用相同的 xpath 在 ff 上运行脚本,但它失败了。我很难给出适当的 xpath 来识别对象。
任何帮助将不胜感激。
【问题讨论】:
-
请提供您的 xpath。并尝试类似
//img[@title='Add and Select More'] -
除非绝对必要,否则我建议不要使用 xpath。
-
是的,避免使用 xpath,我从来没有将它与 watir 一起使用。没有它,代码读起来会更好。如果以下两个答案都不适合您,那么这件事是否会在框架内?
标签: xpath watir watir-webdriver