Protractor return an object but expected - value of element.getText()

不想你离开。 提交于 2019-12-05 05:11:15

getText() returns a promise. If you want to log an actual value, you need to resolve it:

element(by.xpath('(//*[@class="k-link"])[2]')).getText().then(function (value) {
    console.log(value);

    expect(columnSorting.acpColumn.getText()).to.eventually.equal(value);
});

Note that expect() is "patched" in protractor/jasminewd to resolve promises implicitly. In other words, you can assert getText() being equal to the desired text:

expect(element(by.xpath('(//*[@class="k-link"])[2]')).getText()).toEqual('My Text');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!