使用WebdriverIO和Mocha + Chai进行测试时,如何迭代HTML列表中的每个元素?

时间:2017-10-05 04:37:00

标签: testing automated-tests mocha chai webdriver-io

我试图断言某个<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>元素的数组和迭代的正确方法是什么?

0 个答案:

没有答案