量角器“toContain"错误 [英] Protractor 'toContain' error

查看:74
本文介绍了量角器“toContain"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的期望:

expect(mandatoryFields[index].getAttribute('class')).toContain('error');

这是控制台中的错误:

预期['formControl ng-pristine ng-untouched ng-valid ng-empty ng-valid-maxlength error'] 包含'error'.

即使类包含 ERROR 类名,量角器仍然抛出错误.可能是什么原因?任何帮助!!!

Eventhough the class contains ERROR class name, protractor is still throwing error. What could be reason? Any help!!!

推荐答案

尝试使用 toMatch 代替 toContain.toContain 用于检查数组中是否存在所需的值.而 toMatch 使用正则表达式来验证任何值中存在的文本.

Instead of toContain try using toMatch. toContain is used to check whether the required value is present in an array or not. whereas toMatch uses regex for validating the text present in any value.

这篇关于量角器“toContain"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆