One possibility is that if an item is loaded dynamically, that item may not be loaded at the time your test runs. This way you can wait a few seconds for the item to be available.
var EC = protractor.ExpectedConditions; var yourElement = element(by.css('.icon-cancel')); browser.wait(EC.presenceOf(yourElement), 5000);
source share