0
我運行它迭代元素,並在其上點擊,如果他們有一個活躍的類,然後檢查測試,這是我目前的測試:NightWatch.js測試失敗時,它不應該?
'testing if executing a function works': function(client) {
client.elements('css selector', '#home-main-content .swiper-container-vertical>.swiper-pagination-bullets .swiper-pagination-bullet', function(res) {
var numberOfElements = res.value.length;
for (var i = 1; i <= numberOfElements; i++) {
clicked('.swiper-pagination-bullet:nth-of-type' + '(' + i + ')')
}
function clicked(iteration) {
client.click(iteration, function(res2) {
client.assert.cssClassPresent(iteration, '.swiper-pagination-bullet swiper-pagination-bullet-active');
})
}
}).end();
}
的當前錯誤我在控制檯得到的是這個:
Testing if element <.swiper-pagination-bullet:nth-of-type(1)> has css class:
".swiper-pagination-bullet swiper-pagination-bullet-active".
- expected "has .swiper-pagination-bullet swiper-pagination-bullet-active"
but got: "swiper-pagination-bullet swiper-pagination-bullet-active"
正如你所看到的,它看起來像我的測試應該通過。似乎「有」這個詞就是導致我的測試失敗的原因。有沒有辦法消除這種情況?