【问题标题】:Stale element reference: element is not attached to the page - Protractor过时的元素参考:元素未附加到页面 - 量角器
【发布时间】:2018-01-04 14:58:45
【问题描述】:

当我运行量角器测试以检查 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');

任何帮助或指导将不胜感激!

谢谢!

克里斯蒂

编辑

获得不同错误的进一步进展 Failed: Cannot read property 'bind' of undefined

把它塑造成一个页面对象类:

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

再次感谢任何建议,至少它正在找到它但无法阅读它!

【问题讨论】:

    标签: javascript protractor e2e-testing angular-toastr


    【解决方案1】:

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

    【讨论】:

    • 仍然出现同样的错误:失败:过时的元素引用:元素未附加到页面文档(会话信息:chrome=63.0.3239.84)
    • 在等待之前尝试:browser.waitForAngularEnabled(false);
    • 这个元素是闪烁还是重新加载?另一种猜测:将waitForAngular替换为browser.wait(EC.stalenessOf(element(by.className('toast-success toast ng-trigger ng-trigger-flyInOut'))),5000);
    • Nope not reloading or blinking got the following error with what you ask - Failed: stale element reference: element is not attach to the page document
    • 查看我上面的编辑 - 出现无法读取绑定的新错误
    猜你喜欢
    • 2017-12-13
    • 2019-04-27
    • 2016-10-13
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多