Getting a Failed: stale element reference: element is not attached to the page document error when I run my protractor test to check the text in a toast pop up message. I have tried element.all but so no avail:
My expect statement is
it('Delete toast pop up', function() {
var EC = protractor.ExpectedConditions;
publisher_whitelist_page.deleteButtonClick();
browser.wait(EC.visibilityOf(element(by.className('toast-success toast ng-trigger ng-trigger-flyInOut'))),5000);
expect(element.all(by.className('toast-success toast ng-trigger ng-trigger-flyInOut')).getText()).toEqual('Ip address removed');
Any help or guidance would be greatly appreciated!
Thanks!
Kirsty
EDIT
Bit of further progress getting the different error of Failed: Cannot read property 'bind' of undefined
Shaped it into a page object class:
this.popupToastIP = function(){
element.all(by.className('toast-success toast ng-trigger ng-trigger-flyInOut')).then(function(){
element(by.className('toast-success toast ng-trigger ng-trigger-flyInOut')).getText();
});
and my expect:
browser.wait(EC.visibilityOf(publisher_whitelist_page.popupToastIP),5000);
expect(publisher_whitelist_page.popupToastIP.toEqual('Ip address removed'));
again any advice would be appreciated at least it is finding it but can't read it!
You can replace your two last lines with:
browser.wait(EC.textToBePresentInElement(element(by.className('toast-success toast ng-trigger ng-trigger-flyInOut')), 'Ip address removed'), 5000);