5

Protractor works well on Angular 1 but after upgrading my app to an hybrid Angular 1+2 I get this error:

Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability http://errors.angularjs.org/1.4.9/ng/test"

It seems a common error when you don't have a ng-app tag <div ng-app=myAppManager"> in your Angular 1 app and can be easily fixed wiyh rootElement : 'html' in your protractor config file but it doesn't seem to change anything on hybrid app.

I tried rootElement : 'html' or even useAllAngular2AppRoots: true.

I suspect the problem comes from the asynchronous loading of the hybrid angular (from the upgrade doc):

One notable difference between angular.bootstrap and upgradeAdapter.bootstrap is that the latter works asynchronously. This means that we cannot assume that the application has been instantiated immediately after the bootstrap call returns.

my config file:

exports.config = {
    framework: 'jasmine2',
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['protractor.js'],
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 50000,
    },
    allScriptsTimeout: 50000,//seb
    capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {
            'prefs': {
                'profile.managed_default_content_settings.notifications':2
            }
        }
    },
    rootElement : 'html',
    // useAllAngular2AppRoots: true,
    jasmineNodeOpts: {
        realtimeFailure: true
    },
    onPrepare: function() {
      var failFast = require('jasmine-fail-fast');
      jasmine.getEnv().addReporter(failFast.init());
    }
}
Sebastien Horin
  • 10,803
  • 4
  • 52
  • 54

1 Answers1

2

Protractor team has fixed with this:

https://github.com/angular/angular/pull/7603

Edit: I haven't tested it yet

Edit 2: Doesn't seem to work, I went back to angularJs (version 1)

Edit 3: I moved to React

Sebastien Horin
  • 10,803
  • 4
  • 52
  • 54
  • From what I'm seeing this still is not working. My angular pages fail with: Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability I'm using RC5 and have set ng12Hybrid: true in my protractor config. – David Parish Aug 31 '16 at 18:23
  • has this been fixed? – raneshu Mar 17 '17 at 17:33
  • @Sebastien Horin a better choise would have been to switch from protractor to cypress.. – scipper Aug 29 '19 at 06:54
  • @scipper I use Cypress with React, Angular killed himself with this lack of support. They are late now. – Sebastien Horin Aug 29 '19 at 12:29