我有一个带有元素名称的数组:
names=['tdColumn1','tdColumn2','tdColumn3']
而且我不想检查它们是否不可见:
expect(actual).to all(not_be_visible)
但是be_not_visible
, not_visible
, not_be_visible
,.not_to all(be_visible)
不是正确的方法。什么方法是正确的?
我有一个带有元素名称的数组:
names=['tdColumn1','tdColumn2','tdColumn3']
而且我不想检查它们是否不可见:
expect(actual).to all(not_be_visible)
但是be_not_visible
, not_visible
, not_be_visible
,.not_to all(be_visible)
不是正确的方法。什么方法是正确的?
您可以检查数组,而无需自己遍历它,而是使用包含和所有匹配器/修饰符。这种情况下最好的方法是 .not_to + include。
expect(names).not_to include(be_visible)
一个不那么性感的解决方案是匹配 !(false) which = true。
expect(names).to all(!(be_visible))
遍历每个名称并确保页面没有该文本:
names=['tdColumn1','tdColumn2','tdColumn3']
names.each do |name|
expect(page).not_to have_text name
end