小编pet*_*ppe的帖子

setTimeout函数比它应该更快

我在selenium测试中有以下功能,并且setTimeout功能总是比它应该快25%.在这种情况下,要等待20秒,并在15秒后完成功能.

test.describe('basic login test',function(){
    this.timeout(timeout);
    // variables
    test.before(...);

    test.it.only('Test', function(done){
        testLoginPage.load().then(...)
        .then(...).then(...)
        .then(...).then(...)
        .then(function(){
            var first = "1st: " + new Date().getTime();
            console.log(first);    
            setTimeout(function(){
                driver.getTitle().then(function(title){
                    assert.equal(title, 'Tittle', 'Error.');
                });
                console.log(first);
                console.log("2nd: " + new Date().getTime());
                done();
            }, 20000);
       }).then(...)
    });
    test.after();
});
Run Code Online (Sandbox Code Playgroud)

输出:

1st: 1457706590459
1st: 1457706590459
2nd: 1457706605462
Run Code Online (Sandbox Code Playgroud)

javascript selenium node.js webstorm

2
推荐指数
1
解决办法
178
查看次数

标签 统计

javascript ×1

node.js ×1

selenium ×1

webstorm ×1