2017-08-07 24 views
1

我想從列表中刪除和項目,它需要很長時間在應用程序中刪除此元素,所以我想等到這個元素被刪除,然後驗證這個項目不在頁面上。如何等待項目從列表中刪除

this.GroupList = element.all(by.repeater("Group in GroupList | orderBy: order"));

現在我基於其名稱getAttribute('aria-label')上面的列表中,我如何使用ExpectedConditions.stalenessOf OR ExpectedConditions.invisibilityOf等到從列表中的一個元素從DOM刪除刪除元素。

回答

1

如果你有這個指定的中繼項目的引用,你可以使用stalenessOf Expected Condition,例如:

// page object 
this.GroupList = element.all(by.repeater("Group in GroupList")); 

// test 
var itemToBeDeleted = pageObject.GroupList.get(5); 

// delete an item here 

browser.wait(EC.stalenessOf(itemToBeDeleted), 5000); 

請注意,您不需要在轉發定位的「排序依據」的一部分。


另一個想法是等待數由一個帶有自定義有望條件下降:

function waitForCount(elementArrayFinder, count) { 
    return function() { 
     return elementArrayFinder.count(function (actualCount) { 
      return actualCount === count; 
     }); 
    }; 
} 

用法:

pageObject.GroupList.count().then(function (countBefore) { 
    // delete item here 

    browser.wait(waitForCount(pageObject.GroupList, countBefore - 1)); 
}); 
+0

識別和刪除元素我用它命名並刪除它,如何使用預期條件來識別此元素。 'exports.DeleteGroupByDisplayName = function(displayName){this.GroupList.filter(function(elem,index){0}}返回elem.getAttribute('aria-label')。then(function(text){ return text.toUpperCase )=== displayName.toUpperCase(); }); })。then(function(filteredElements){ filteredElements [0] .click(); }); this.DeleteBtn.click(); this.DeleteConf.click(); }; ' – ssharma

+0

@ssharma我認爲你應該能夠從'then()'返回'filteredElements [0]',這將使'DeleteGroupByDisplayName'返回'ElementFinder',你可以傳遞給'stalenessOf'。 – alecxe

+0

Thanks @ alecxe這工作。 – ssharma