toEqual by binding不起作用
toEqual by binding is not working
我必须通过以下方式断言文本:
expect(accessPolicyPage.accessPolicyName).toEqual(element.all(by.binding("pol.name")).get(0).getText());
它给了我一些很长的错误,如下所示。
"访问策略名称01"应等于({ptor_:({controlFlow:Function,schedule:Function,setFileDetector:Function,getSession:Function,getCapabilities:Function,quit:Function,actions:Function,touchActions:Function,executeScript:Function,executeSyncScript:函数,调用:函数,等待:函数,睡眠:Function,getWindowHandle:Function,getAllWindowHandles:Function,getPageSource:Function,close:Function,getCurrentUrl:Function,getTitle:Function,findElementInternal_:Function,findElementsInternal_:函数,takeScreenshot:函数,管理:功能,switc
您在控制台上看到的是一个"可怕"的promise对象表示。如果您需要一个真实的值,使用then()
:显式地解析promise
element.all(by.binding("pol.name")).get(0).getText().then(function (text) {
expect(accessPolicyPage.accessPolicyName).toEqual(text);
});
或者,由于accessPolicyPage.accessPolicyName
是预先定义的实际文本,您可以交换匹配器中的内容,然后让expect()
隐式解析promise:
expect(element.all(by.binding("pol.name")).get(0).getText()).toEqual(accessPolicyPage.accessPolicyName);
此选项更简单,通常推荐使用。
expect(somePromise).toEqual(someString);
expect(somePromise).toEqual(anotherPromise);
但这个不会:
expect(notPromise).toEqual(somePromise);
getText()返回一个promise,而不是需要处理的文本。
Protractor:element.getText()返回一个对象,而不是字符串
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- 简单的javascript在Shopify中不起作用
- Recaptcha在IE7和IE8中不起作用
- Ember Data DS.Model's set函数不起作用
- JsFiddle上的鼠标事件不起作用
- 我的AngularJS表达式没有'不起作用
- 点击按钮输入不起作用
- 面向对象的Javascript代码在IE7中不起作用
- 分部隐藏在jquery中不起作用
- 在phonegap应用程序内部重定向不起作用
- Array.length似乎不起作用;console.log则显示其他情况
- $ionicplatform内的$scope不;不起作用
- 我的javascript for循环不起作用
- Meteor-添加用户自定义字段的方法不起作用
- 追加Jquery后的Binding Click事件不起作用
- toEqual by binding不起作用
- binding scroll事件在AngularJS中不起作用
- Angular JS - Binding view和app.js - ng-repeat不起作用