{"action":"created","issue":{"url":"https://api.github.com/repos/angular/protractor/issues/279","labels_url":"https://api.github.com/repos/angular/protractor/issues/279/labels{/name}","comments_url":"https://api.github.com/repos/angular/protractor/issues/279/comments","events_url":"https://api.github.com/repos/angular/protractor/issues/279/events","html_url":"https://github.com/angular/protractor/issues/279","id":23034765,"number":279,"title":"feat(poll angular $digest) waitForAngular insufficient for complex apps","user":{"login":"eahutchins","id":3834227,"avatar_url":"https://avatars.githubusercontent.com/u/3834227?v=3","gravatar_id":"","url":"https://api.github.com/users/eahutchins","html_url":"https://github.com/eahutchins","followers_url":"https://api.github.com/users/eahutchins/followers","following_url":"https://api.github.com/users/eahutchins/following{/other_user}","gists_url":"https://api.github.com/users/eahutchins/gists{/gist_id}","starred_url":"https://api.github.com/users/eahutchins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eahutchins/subscriptions","organizations_url":"https://api.github.com/users/eahutchins/orgs","repos_url":"https://api.github.com/users/eahutchins/repos","events_url":"https://api.github.com/users/eahutchins/events{/privacy}","received_events_url":"https://api.github.com/users/eahutchins/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/protractor/labels/type:%20feature%20request","name":"type: feature request","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2013-11-21T00:03:01Z","updated_at":"2015-03-31T20:19:50Z","closed_at":"2014-03-05T06:16:53Z","body":"I have an [open issue on ngScenario](https://github.com/angular/angular.js/issues/4814) which I think applies to protractor as well. Our app has a lot of asynchronous processing (via socket.io) and lazy-loaded states/code via ui-router, as far as I can tell `waitForAngular()` really only waits for angular processing and `$http` requests to idle. At least when I try to test our login (which works under karma/ngScenario with the polling function I implemented in the pull request) it sporadically fails under protractor:\r\n\r\n```javascript\r\n// from our testing library:\r\nmodule.exports.login = function login(username, password, expectFail) {\r\n\r\n   var ptor = protractor.getInstance();\r\n\r\n   it('should ' + (expectFail ? 'not ' : '') + 'log in', function() {\r\n      console.log('login', username + '/' + (password || \"''\"));\r\n\r\n      // navigate to '/' and wait for the login \r\n      ptor.get('/');\r\n\r\n      ptor.waitForAngular();\r\n\r\n      element(by.model('user.name')).sendKeys(username);\r\n      if (password) element(by.model('user.password')).sendKeys(password);\r\n\r\n      element(by.id('login-button')).click();\r\n\r\n      ptor.waitForAngular();\r\n\r\n      if (expectFail) {\r\n         expect(element(by.id('login-failed-alert')).getText()).toBeTruthy();\r\n      } else {\r\n         expect(element(by.xpath('//div[@wt-embed=\"AppLauncher\"]'))).toBeTruthy();\r\n         expect(element(by.id('logout-menu-item'))).toBeTruthy();\r\n      }\r\n   });\r\n}\r\n```\r\n\r\nWith the `ptor.waitForAngular()` calls I can get the logins to pass 2/3rds of the time, without them it seldom passes.\r\n\r\nFor complex cases like this I think polling on `$digest` with positive success and failure cases and a timeout is probably the best way to go (though I'd be glad to hear of a simpler solution). How hard would this be to add to protractor?\r\n"},"comment":{"url":"https://api.github.com/repos/angular/protractor/issues/comments/88232203","html_url":"https://github.com/angular/protractor/issues/279#issuecomment-88232203","issue_url":"https://api.github.com/repos/angular/protractor/issues/279","id":88232203,"user":{"login":"bvaughn","id":29597,"avatar_url":"https://avatars.githubusercontent.com/u/29597?v=3","gravatar_id":"","url":"https://api.github.com/users/bvaughn","html_url":"https://github.com/bvaughn","followers_url":"https://api.github.com/users/bvaughn/followers","following_url":"https://api.github.com/users/bvaughn/following{/other_user}","gists_url":"https://api.github.com/users/bvaughn/gists{/gist_id}","starred_url":"https://api.github.com/users/bvaughn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvaughn/subscriptions","organizations_url":"https://api.github.com/users/bvaughn/orgs","repos_url":"https://api.github.com/users/bvaughn/repos","events_url":"https://api.github.com/users/bvaughn/events{/privacy}","received_events_url":"https://api.github.com/users/bvaughn/received_events","type":"User","site_admin":false},"created_at":"2015-03-31T20:19:50Z","updated_at":"2015-03-31T20:19:50Z","body":"Thanks for the updated info."}}