小编hel*_*hek的帖子

量角器等待命令无法等待引导模式出现

场景:每当用户使用不正确的凭据登录时,引导模式将显示1-2秒,并显示消息"抱歉,凭据不正确".下面是模态的HTML.

<div class="modal-content">
<div class="modal-body note-error text-center ng-binding"> Sorry, invalid credentials! </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我需要验证预期的错误文本是否等于实际的错误文本.

我的代码

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

 };
Run Code Online (Sandbox Code Playgroud)

Spec.js

expect(Login_Page.getErrorText()).toMatch('Sorry, invalid credentials!');
Run Code Online (Sandbox Code Playgroud)

产量

消息:预计''匹配'抱歉,凭证无效!'.

我不知道为什么这个等待不起作用.

javascript automation jasmine angularjs protractor

9
推荐指数
1
解决办法
627
查看次数

标签 统计

angularjs ×1

automation ×1

jasmine ×1

javascript ×1

protractor ×1