2017-10-06 3 views
1

スクリプトを実行する待機条件を作成しようとしています。待機する必要があるかどうかによって戻り値に基づいて決定されます。 私は分度器のexecuteScript機能とブラウザの待機を使用しています:プロトラクターブラウザーがブール値を待機する条件

this.activeConnections = function(jsl) { 
console.log("Inside Active Connections"); 
switch (jsl) { 
case checkEnum.jQuery: 
console.log("Jquery Enum"); 
return browser.executeScript("return jQuery.active;").then(function(count) { 
console.log("The count is "+count); 
return count == 0; 
}); 
default: 
browser.logger.info("No asynchronous check performed."); 
break; 
} 
}; 

私がtrueに評価されます実行されるスクリプトまで待機する待機状態を期待していたが、それは

this.waitForActiveConnections = function() { 
console.log("Inside Wait for Active Connections"); 
var condition = until.and(this.activeConnections(checkEnum.jQuery),false); 
console.log("Whats this condition "+ condition); 
return browser.wait(condition,30000); 
}; 
+0

は簡易版で働いて、それを手に入れた: 'this.waitForActiveConnections =機能(){ はconsole.log( "インサイドはアクティブ接続を待ちます"); return browser.wait(function(){ //条件がtrueになるまで待ちます。 return browser.executeScript( "return jQuery.active;")then(function(count){ console.log + count); 戻りカウント== 1; }); }、3000); }; ' –

答えて

0

主な問題は機能していませんあなたのカスタム期待条件が実行可能ファイルを返す必要があることです。browser.wait()が継続的に実行される関数です。ような何か:

this.activeConnections = function(jsl) { 
    return function() { 
     switch (jsl) { 
      case checkEnum.jQuery: 
       return browser.executeScript("return jQuery.active;").then(function(count) { 
        return count == 0; 
      }); 
      default: 
       browser.logger.info("No asynchronous check performed."); 
       return true; 
       break; 
     } 
    } 
} 
関連する問題