AssertionError: expected [ true ] to be true

邮差的信 提交于 2019-12-06 10:22:39

It seems like this.getWidget('contacts').isNamesDisplayed() is returning an array value [true] instead of true. you need to change your expect statement as below.

this.expect(this.getWidget('contacts').isNamesDisplayed()).to.eql([true]).and.notify(next);

The accepted answer is great. The accepted answer reiterates the complaint from Protractor, which is frustrating but very clear:

... returning an array value [true]...

Apparently that is the behavior of the OP's function isNamesDisplayed. But there may be other reasons:

In my case, I accidentally used $$, instead of $, and I was expect($$('div.to-test').isDisplayed()).toBe(true). $$ is a "Shorthand function for finding arrays of elements by css" .

So be aware that one character, $, could be the cause of (and solution to) all life's problems: expect($('div.to-test').isDisplayed()).toBe(true),

(or as the accepted answer says, you could just... "change your expectations" :) )

expect($$('div.to-test').isDisplayed()).toBe([true]);

Maybe makes more sense for something you actually expect to repeat,for example the <li> list items in a <ul>

expect($$('ul.to-test li').isDisplayed()).toBe([true, true, true]);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!