【发布时间】:2016-01-04 11:07:33
【问题描述】:
在我正在测试的应用程序中,我们使用 angular $window service 重定向到不同的 URL。
例如: 当你点击一个按钮时,它会通过以下方式将你重定向到一个新页面:
$window.location.assign('/redirect/to/this/newURL');
在angular docs for $window 中,他们提供了这个量角器示例:
index.html:
<script>
angular.module('windowExample', [])
.controller('ExampleController', ['$scope', '$window', function($scope, $window) {
$scope.greeting = 'Hello, World!';
$scope.doGreeting = function(greeting) {
$window.alert(greeting);
};
}]);
</script>
<div ng-controller="ExampleController">
<input type="text" ng-model="greeting" aria-label="greeting" />
<button ng-click="doGreeting(greeting)">ALERT</button>
</div>
量角器.js:
it('should display the greeting in the input box', function() {
element(by.model('greeting')).sendKeys('Hello, E2E Tests');
// If we click the button it will block the test runner
// element(':button').click();
});
测试状态:
如果我们点击按钮,它将阻止测试运行器。
我想知道这到底是什么意思。我很好奇它为什么以及如何阻止量角器测试运行器?这对尝试测试该功能有何影响?看起来ignore.Synchronization=true 可能有助于在其中一些情况下进行测试,但希望我能更好地理解为什么 $window 服务会破坏测试,以期找到测试这些情况的好解决方案。
【问题讨论】:
标签: angularjs window protractor