- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 Cucumber 一年了,几周后我就在其中添加了 page-object-gem。当我执行测试时,我收到消息:
DEPRECATION WARNING
You are calling a method named checkbox at commentPage.rb:23:in `block in delete_comment'.
This method does not exist in page-object so it is being passed to the driver.
This feature will be removed in the near future.
Please change your code to call the correct page-object method.
(我对其他情况也有同样的看法,但这个“微不足道”的例子应该更容易解释)
我正在寻找避免这种情况的方法,但它看起来很复杂。
为了测试,我正在检查一个页面,上面有一个表格。每行显示一行,我需要选中特定行的复选框。
我在 pageObject 中的代码:
table(:comment_list, :class => 'comments')
button(:delete, :text => "Delete")
def delete_comment (text)
self.comment_list_element.each do |row|
if row.text.include? "#{text}"
row.checkbox.set
self.delete
return true
end
end
false
end
我是否需要对我的 table 进行预处理才能在测试期间使用它?
最佳答案
您收到警告是因为您正在调用 Watir 上的方法而不是页面对象(表格行上的 checkbox
方法)。如果你想访问复选框,你可以简单地调用将返回嵌套元素的方法。这会将调用的那部分更改为 row.checkbox_element
。但是你下次打电话也会遇到同样的问题。首先,CheckBox 上不存在 set
方法。在页面对象中,方法是check
和uncheck
。完整的调用应该是:
row.checkbox_element.check
您收到弃用错误的原因是因为我计划在将来删除对底层驱动程序的调用转发。这种能力在复杂情况下确实会导致很多问题。
关于watir - 如何避免为复选框弃用页面对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12479624/
我是一名优秀的程序员,十分优秀!