尝试获取Toast警报文本时出现超时错误

时间:2017-07-18 09:58:17

标签: angularjs protractor

Toast alert DOM结构:



<uib-alert id="alert-message-0" class="cs-toast-alert ng-binding ng-scope" ng-repeat="alert in headerModel.alerts()" type="success"
close="" ng-style="{bottom: (((headerModel.alerts().length - $index ) * 70) - 48) + 'px'}" 
ng-bind-html="headerModel.trustAsHtml(alert.msg)" style="bottom: 22px;">Successfully completed discharge</uib-alert>
&#13;
&#13;
&#13;

使用的方法是:

var EC = protractor.ExpectedConditions;
            browser.wait(EC.visibilityOf(element(by.id("alert-message-0"))),8000).then(function () {
                return element(by.id('alert-message-0')).getAttribute('innerText').then(function (ttmessage) {
                    expect(ttmessage).toContain('Successfully completed discharge');
                    //browser.ignoreSynchronization = false;
                });
            });

获取错误:   - 失败:在8856ms之后等待超时

1 个答案:

答案 0 :(得分:0)

试试:

var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(element(by.id('alert-message-0'))), 8000);
return expect(element(by.id('alert-message-0')).getText()).to.eventually.equals('Successfully completed discharge');