2017-11-17 8 views
0

私はエンドツーエンドのテストの分度器に取り組んでおり、ボタンをクリックする前にステータスインジケータが消えるのを確認する必要があります。今私はそれをすることができません。 invisibilityOf()stalenessOf()を使用しようとしましたが、動作しません。分度器のステータスインジケータを確認できません

ここでのPageObjectの私のコードです:

public isNotPresent(elem) { 
    return browser.wait(protractor.ExpectedConditions.stalenessOf(elem), 5000).then(function() { 
     console.log("Status indicator is not present in DOM"); 
     return true; //success 
    },function() { 
     console.log("Status indicator is present in DOM"); 
     return false; //Failure 
    }); 
} 

public waitForStatusIndicator(){ 
    console.log('in method wait for status indicator'); 
    return this.isNotPresent(element(by.css('#api-status-indicator'))).then((isNotPresent)=>{ 
     return isNotPresent; 
    }); 
} 

がここにあります:それは<#APIのステータス・インジケータ>、その他の要素は、クリックを受け取ることになるポイント(540823)でクリックできません」というエラーが表示さ私が間違っているつもりです

PageObject.waitForStatusIndicator().then(function (isNotPresent) { 
     if(isNotPresent == true) { 
     someButton.click(); 
     return expect(browser.getCurrentUrl()).not.toBe(browser.baseUrl + "/login"); 
     } 
}) 

:どこでステータスインジケータをチェックしようとしていますか?

+0

ノードを完全に削除すると、それはもう見つからないのが普通です。 'stalenessOf'を使う前に、それがすべて最初に存在するかどうかを確認してください。 –

答えて

1

要素が最初に表示され、DOMになかった場合は、最初に要素が表示されていることを確認してから、もう一度表示されるまで待つ必要があります。このような

総合的な何か:

public isNoLongerPresent(elem) { 
    //NOTE: If any of the expected conditions don't happen, your code times out. 
    //No need for false-check or similar 
    var EC = protractor.ExpectedConditions; 
    browser.wait(EC.presenceOf(elem), 5000); 
    browser.wait(EC.visibilityOf(elem), 5000); //Note, that visibilityOf requires presence 
    return browser.wait(EC.stalenessOf(elem), 5000); 
} 

public waitForStatusIndicator(){ 
    console.log('in method wait for status indicator'); 
    return this.isNoLongerPresent(element(by.css('#api-status-indicator'))); 
} 

そして、あなたのスペック: 任意のthen()の必要はもうありません。プロトラクターは同期を実行し、途中でfalseの場合は、コードがタイムアウトします。

PageObject.waitForStatusIndicator(); 
someButton.click(); 
return expect(browser.getCurrentUrl()).not.toBe(browser.baseUrl + "/login"); 
関連する問題