我试图断言某个<ol>
元素中的每个项都存在。我可以在SO和其他地方找到的最接近的解决方案是使用.elements
,但这仍然不起作用。 <ol>
元素的长度在不同页面上有所不同,因此无法将其硬编码到测试中。请参阅下面的我当前的测试,该测试应该在i.should.not.exist
失败但是通过。
it('category hierarchy navigation test',function() {
return client
.url(Page.url)
.then(function() {
ItemPage.categoryHierarchy.should.exist;
})
.then(function() {
return client.elements(ItemPage.categoryHierarchy, function(err, res){
for (let i in res.value) {
i.should.not.exist;
}
})
})
})
获取<li>
内的<ol>
元素的数组和迭代的正确方法是什么?