How to handle Watir::Exception::UnknownObjectException:
我正在使用 watir 来使用 while 循环自动删除元素,但是当脚本到达末尾时,它会出错,因为 while 循环所依赖的元素不再可见。无论如何要让 Watir 继续进行测试吗?
这是我的代码示例:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
class Delete_element
def org_roster_remove |
这是错误:
Watir::Exception::UnknownObjectException: unable to locate element, using {:data_class=>”home.group.edit_group_btn”, :tag_name=>”a”}
- 我认为您想使用 present? 而不是 visible?。查看这个最近的 SO 问题:stackoverflow.com/questions/25877525/…
我会使用 .present?而不是 .visible?
还可以考虑使用 .wait_until_visible 而不是hibernate。请参阅 Watir-webdriver 等待。
另外,研究一个页面对象框架,例如 Cheezy 的页面对象 gem
- 谢谢你。 Cheezy 的东西很有帮助
来源:https://www.codenong.com/26391070/