我在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)