场景:每当用户使用不正确的凭据登录时,引导模式将显示1-2秒,并显示消息"抱歉,凭据不正确".下面是模态的HTML.
Sorry, invalid credentials!
我需要验证预期的错误文本是否等于实际的错误文本.
我的代码
PageObject.js
var errorModal = element(by.css('.modal-body.note-error.text-center.ng-binding')); this.getErrorText = function(){ var until = protractor.ExpectedConditions; browser.wait(until.textToBePresentInElement(errorModal, "Sorry, invalid credentials!"), 3000, "Not able to find"); return errorModal.getText(); };
Spec.js
expect(Login_Page.getErrorText()).toMatch('Sorry, invalid credentials!');
产量
消息:预计''匹配'抱歉,凭证无效!'.
我不知道为什么这个等待不起作用.