No injector found for element argument to getTestability

前端 未结 5 2060
遇见更好的自我
遇见更好的自我 2020-12-05 19:32

I\'m trying to run this tutorial against my own AngularJS code. I can\'t get past the first test. Any attempt to pull any information from my page gets this error:

5条回答
  •  生来不讨喜
    2020-12-05 20:17

    Like the accepted answer implies, the problem lies in letting protractor know what's the root of your app, this is where ng-app is defined. By default this is expected to be the tag but your code seems to have it somewhere else. Nevertheless you can actually change that behavior in the config file.

    From the Protractor reference config file:

      // CSS Selector for the element housing the angular app - this defaults to
      // body, but is necessary if ng-app is on a descendant of .
      rootElement: 'body',
    

    For example, if your ng-app is within a div like this:

    You could use

    rootElement: '#my-app'

    Since it's a CSS selector, you could also use the square brackets syntax to select by attribute, like this:

    rootElement: '[ng-app]'

    This would select the element that contains the attribute ng-app, no matter which one it is.

提交回复
热议问题