2016-03-14 29 views
1

我試圖用量角器來選擇一排,計算行加載等,這似乎並不奏效:如何等待行與量角器

var GridTestUtils = require('./gridObjectTestUtils.spec.js'); 

var GridTestObj = new GridTestUtils('exampleGrid'); 
var Grid = GridTestObj.getGrid(); 

browser.wait(function(){ 

    return Grid.isPresent(); 

}, 1000).then(function(){ 

    GridTestObj.expectRowCount(25); 

}); 

它好像它是試圖找到行正在載入前。測試保持與「預計0至25等於」失敗。

我可以,如果我使用browser.sleep,但必須有比這更好的解決它的工作。

我如何告訴量角器等角度UI電網完全加載?

回答

0

我會做到這一點與browser.wait()定製的預期條件

var rows = Grid.element(by.css('.ui-grid-render-container-body')).all(by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index')); 

browser.wait(function() { 
    return rows.count().then(function (countValue) { 
     return countValue > 0; 
    }); 
}, 5000); 

在這種情況下,直到它的計算結果爲真或超時發生protractor將執行傳遞到browser.wait()連續函數(5秒)。