Testing 如何在考试中睡觉或等待?

Testing 如何在考试中睡觉或等待?,testing,cucumber,Testing,Cucumber,我想等X秒: Background: Given I open the game And I wait for 10 seconds 命令呢 this.Given(/^I wait for (\d+) seconds$/,function(n){ this.driver.sleep(n.to_i) }); 这是行不通的,你知道怎么做吗?找到了这个办法,但这可能不是最好的办法: this.Given(/^I wait for (\d+) seconds$/,functi

我想等X秒:

Background:
    Given I open the game
    And I wait for 10 seconds
命令呢

this.Given(/^I wait for (\d+) seconds$/,function(n){
    this.driver.sleep(n.to_i)
});

这是行不通的,你知道怎么做吗?

找到了这个办法,但这可能不是最好的办法:

this.Given(/^I wait for (\d+) seconds$/,function(n){
    var timerDone = false;
    setTimeout(function(){
        timerDone = true;
    }, n * 1000)
    this.driver.wait(function(){
        return timerDone;
    }, Infinity).then(function(){
        console.log("end")
    })
});