我有一个量角器测试,输入登录数据并单击登录按钮,我希望检查 Angular 变量的值。
被单击元素的 ng-click 是 doLogin(),它在控制器文件中定义为:
$scope.doLogin = function(){
console.log('login -- todo');
// remember email used
localStorageService.add('lastKeyEmail', $scope.data.login.key.email);
// todo - make dynamic
$scope.authentication.user = true;
// set email of logged in user
// todo: would need to be done in user service (set user details received from server)
Authentication.setEmail($scope.data.login.key.email);
// overwrite password in memory
$scope.data.login.password = "thispasswordisdeletedsoyoucantreadit";
};
如何对 $scope.authentication.user 的值使用 Protractor 的 Expect() ?
有一个函数叫做evaluate
它允许您计算给定元素的角度表达式。
选择要检查其范围的 DOM 元素,然后调用评估。文档中有一个例子:
http://angular.github.io/protractor/#/api?view=ElementArrayFinder.prototype.evaluate http://angular.github.io/protractor/#/api?view=ElementArrayFinder.prototype.evaluate
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)