protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Timed out waiting for angular1 app

Open jessehonest opened this issue 9 years ago • 2 comments

Protractor is timing out waiting for the angular1 app. However if I get the angular version it does return 1.5.3 as expected. I can turn off synchronization but that defeats the purpose of using protractor. Any help is appreciated. Thank you.

  • Node Version: 6.9.4
  • Protractor Version: 5.0.0
  • Angular Version: 1.5.3
  • Browser(s): Chrome v56.0.2924.76
  • Operating System and Version OSX 10.11.6
  • Mocha Version: 3.2.0

Page Object

class HomePage {
  visit() {
    browser.get(`https://${h.auth}@my.example.com`);
    console.log(`Angular version: ${ await browser.executeScript('return window.angular.version.full;')}`);
    browser.waitForAngular();
  }
}
module.exports = HomePage;

Spec

'use strict`;
let HomePage = require('./home.page.js');

describe('Test', function() {
  it('One', function() {
    let homePage = new HomePage();
    homePage.visit();
  });
});

Console Output:

Test
  One
Angular version: 1.5.3

0 passing(15s)
1 failing

Timed out waiting for asynchronous Angular tasks to finish after 10 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular. 
The following tasks were pending:
 - $timeout: function (){e.$http.get("/status/version").then(function(t){e.handleVersion(t)},function(t){e.checkVersion()})}
 - $timeout: function (){var e=u.leave(h,l);e&&e.then&&e.then(l),u.leave(g)}
  ScriptTimeoutError: asynchronous script timeout: result was not received in 10 seconds
    (Session info: chrome=56.0.2924.76)
    (Driver info: chromedriver=2.26.436421 (6c1a3ab469ad86fd49c8d97ede4a6b96a49ca5f6),platform=Mac OS X 10.11.6 x86_64)
      at WebDriverError (node_modules/selenium-webdriver/lib/error.js:27:5)
      at ScriptTimeoutError (node_modules/selenium-webdriver/lib/error.js:203:5)
      at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:505:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:509:13)
      at doSend.then.response (node_modules/selenium-webdriver/lib/http.js:440:13)
      at process._tickCallback (internal/process/next_tick.js:103:7)
  From: Task: Protractor.waitForAngular()
      at Driver.schedule (node_modules/selenium-webdriver/lib/webdriver.js:816:17)
      at ProtractorBrowser.executeAsyncScript_ (node_modules/protractor/lib/browser.ts:497:24)
      at runWaitForAngularScript (node_modules/protractor/lib/browser.ts:527:21)
      at ProtractorBrowser.waitForAngular (node_modules/protractor/lib/browser.ts:533:12)

jessehonest avatar Feb 01 '17 00:02 jessehonest

I'm curious about Angular version: ${ await browser are you using Babel or something similar to add async/await support? There are known issues mixing async/await with the webdriver control flow.

What happens if you do not mix the two? E.g.

browser.executeScript('return window.angular.version.full;')}`)
  .then((version) => {
    console.log(version);
  })
browser.waitForAngular()

NickTomlin avatar Feb 25 '17 23:02 NickTomlin

Mixing async/await with control-flow based commands can have unexpected results. You either need to await everything, or write synchronous code that relies on the control flow.

The error message lists some pending tasks:

Timed out waiting for asynchronous Angular tasks to finish after 10 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular. 
The following tasks were pending:
 - $timeout: function (){e.$http.get("/status/version").then(function(t){e.handleVersion(t)},function(t){e.checkVersion()})}
 - $timeout: function (){var e=u.leave(h,l);e&&e.then&&e.then(l),u.leave(g)}

If these are periodic tasks, you can switch them to using $interval and Protractor will ignore them. Or, you can increase your timeout to wait for them to finish.

heathkit avatar May 01 '17 02:05 heathkit