Protractor Angular 2 Failed: unknown error: angular is not defined

I’m getting the following error:

  • Failed: unknown error: angular is not defined

This only happens when using angular specific selectors like “by.model”. But selectors such as “by.css” work correctly . This is an Angular 2 app…


it('should set focus', () => {
    //This works
    //var input = element(by.css('myclass'));
    //This fails
    var input = element(by.model('config.value'));
    var highlightedText = browser.executeScript(function getSelectionText()       
         return window.getSelection().toString(); 

exports.config = {
  baseUrl: 'http://localhost:5555',

  specs: [
  exclude: [],

  framework: 'jasmine2',

  allScriptsTimeout: 110000,

  jasmineNodeOpts: {
    showTiming: true,
    showColors: true,
    isVerbose: false,
    includeStackTrace: false,
    defaultTimeoutInterval: 400000
  directConnect: true,

  capabilities: {
    'browserName': 'chrome'

  onPrepare: function() {
    var SpecReporter = require('jasmine-spec-reporter');
    jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: true}));

    browser.ignoreSynchronization = false;

  useAllAngular2AppRoots: true

platform=Windows NT 6.1 SP1 x86_64

I found the answer on the site under developer docs.

Upgrading from 1.x

enter image description here

Right now angular selectors by.model and by.binding are not supported. Its not clear if these are features that are possible or that they are working on for angular 2.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   Is JavaScript's "new" keyword considered harmful?

Similar Posts