我現在有在我的測試規格之一量角器下面的代碼:量角器時序問題
.then(function() {
return button.click();
})
.then(function() {
return element(otherButton).isDisplayed();
})
.then(function(otherButtonIsPresent) {
if(otherButtonIsPresent) {
return browser.wait(EC.elementToBeClickable(element(otherButton)), getWaitTime())
.then(function() {
element(otherButton).click();
return element(continueButton).isPresent();
})
}
})
當我使用Chrome使用--debug-brk
和--inspect
標誌調試,我能夠通過這些檢查和恢復像平常一樣。當我在沒有標誌的情況下運行相同的測試時,測試失敗並在嘗試點擊它之前查找otherButton
期間停頓。
我想知道是否這是因爲在調試過程中,我設置了斷點並等待按鈕顯示在屏幕上,然後再嘗試單擊它們。
我需要確保這個元素在頁面上可見之前試圖點擊它,並想知道是否有另一種方式,如果完成此?
謝謝
嘗試使用browser.wait()與ExpectedConditions沿着使的webdriver到直到某些特定條件。請參閱http://www.protractortest.org/#/api?view=ProtractorExpectedConditions。 –