简体   繁体   English

Nightwatch js断言排序的元素值

[英]Nightwatch js assert element values sorted

Trying to test a filter feature on a table that I built and not sure how to do it with nightwatch. 试图在我建立的桌子上测试过滤器功能,但不确定如何使用夜表。

I can run through and view all the element values, but not sure how to compare them to see if they are less than or equal to the next 我可以浏览并查看所有元素值,但不确定如何比较它们以查看它们是否小于或等于下一个

Then(/^I should expect to see the returned results ordered from least to greatest$/, () => {
    return client
            .elements('css selector', 'td[class=someColumn]', (results) => {
                for(let i = 0; i < results.value.length; i++){
                    client.elementIdText(results.value[i].ELEMENT, (result) => {
                        console.log(result.value);
                        return result.value;
                    })
                }
            });
});

Any pointers are greatly appreciated 任何指针,不胜感激

Add one more .elementIDText() and reduce the length of results.value by 1 to checl the list is sorted or not. 再添加一个.elementIDText()并将results.value的长度减少1,以检查列表是否已排序。

client.elements('css selector', 'td[class=someColumn]', (results) => {
      for(let i = 0; i < results.value.length-1; i++){
            client.elementIdText(results.value[i].ELEMENT, (result1) => {
                   client.elementIdText(results.value[i+1].ELEMENT, (result2) => {
                     if(result1<=result2){
                       }else {
                        return false;}
                    })
             })
       }

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM