Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting testcafe中有没有可以测试表中已排序列的函数?_Sorting_Testing_Automated Tests_E2e Testing_Testcafe - Fatal编程技术网

Sorting testcafe中有没有可以测试表中已排序列的函数?

Sorting testcafe中有没有可以测试表中已排序列的函数?,sorting,testing,automated-tests,e2e-testing,testcafe,Sorting,Testing,Automated Tests,E2e Testing,Testcafe,是否实现了检查列是否按降序显示的功能? 在这种情况下,单击排序,即将名称/电子邮件ID从Z排序到a,然后列表应按字母顺序从Z排序到a 使用testcafe有什么策略可以应用吗?是的,有一个很大的ol“技术上” 如前所述,这不是TestCafe特有的。 这个答案建立在奥巴马的评论之上 如果您正在测试字符串… wait t.expect(cell=compareCell).ok()以测试下降 如果您正在测试数字… wait t.expect(cell).lte(compareCell)测试升序 wa

是否实现了检查列是否按降序显示的功能? 在这种情况下,单击排序,即将名称/电子邮件ID从Z排序到a,然后列表应按字母顺序从Z排序到a

使用testcafe有什么策略可以应用吗?

是的,有一个很大的ol“技术上”

如前所述,这不是TestCafe特有的。
这个答案建立在奥巴马的评论之上

如果您正在测试字符串…

wait t.expect(cell=compareCell).ok()以测试下降

如果您正在测试数字…

wait t.expect(cell).lte(compareCell)测试升序
wait t.expect(cell).gte(compareCell)以测试下降

完整的伪测试用例(用于字符串)

test('应按ASC排序',异步t=>{
const cellSelector=选择器('td[name=“sortable cell”]”);
const cellCount=等待cellSelector.count;
for(设i=0;i期待(cellText您的任务似乎与TestCafe无关。请在上查看所有可用的测试API。检查此任务的算法完全取决于您使用的表及其排序方法实现。例如,如果表上有排序指示符,您可以检查其状态。如果没有指示符,您可以收集对列数据进行排序,并将其与原始数据源进行比较。如果结果相等,则按您希望检查的方式对数据进行排序。如果您可以访问值,则可以确保下一个值始终小于上一个值
test('Should be Sorted ASC', async t => {
    const cellSelector = Selector('td[name="sortable-cell"]');
    const cellCount = await cellSelector.count;

    for (let i = 0; i < cellCount - 1; i++) {
        let cellText = await cellSelector.nth(i).innerText;
        let compareCellText = await cellSelector.nth(i + 1).innerText;

        await t.expect(cellText <= compareCellText).ok();
    }
})