陈旧元素引用:元素未附加到页面 - 量角器

时间:2018-01-04 14:58:45

标签: javascript protractor e2e-testing angular-toastr

获取失败:陈旧元素引用:当我运行量角器测试以检查Toast弹出消息中的文本时,元素未附加到页面文档错误。我尝试过element.all但是没有用:

我的期望陈述是

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');

非常感谢任何帮助或指导!

谢谢!

Kirsty

修改

获得失败的不同错误的进一步进展:无法读取未定义的属性'bind'

将其整形为页面对象类:

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();

});

和我的期望:

browser.wait(EC.visibilityOf(publisher_whitelist_page.popupToastIP),5000);
expect(publisher_whitelist_page.popupToastIP.toEqual('Ip address removed'));  

再次任何建议都会受到赞赏,至少它是找到它但无法读取它!

1 个答案:

答案 0 :(得分:0)

您可以用以下内容替换最后两行: browser.wait(EC.textToBePresentInElement(element(by.className('toast-success toast ng-trigger ng-trigger-flyInOut')), 'Ip address removed'), 5000);