How can I provide the rootelement option while testing the protractor

When I execute node elementexplorer.js http://127.0.0.1:8080/app/view1

I get the following error:

The webdriver error appeared: Error Error while waiting for transfer to synchronize with the page: "The root element (body) does not have an injector. Means that it is not inside the ng application."

Please let me know how to provide the rootelement parameter.

+6
source share
2 answers

Currently rootElement is used by default for the body. If you do not have your ng application in the body, you will get this error. It can be installed manually.

You need to change rootElement. You can do this directly from the interactive view by running:

 browser.rootEl = 'div#ng-app-located-here'; 

Assuming your ng app is in div#ng-app-located-here

+7
source

In this case, you need to indicate on which element your ng-app installed. Add rootElement to your conf.js , for example:

 rootElement: 'div#nested-ng-app' // by default, it is 'body' 

FYI, this is due to the fact that angular transport characters are used as the root for the search - by.binding locators, such as by.binding or by.model , rootElement , quote from the change log :

Custom stacker locators (by.binding, by.model, etc.) use config.rootElement as the root for all of their searches. This meant that config.rootElement was used both to determine how to access the Angular injector, as well as where to start searching for elements. This does not work for all cases, for example, if the dialogue should be a search for elements, but is a child, not a child, ng-app.

+4
source

Source: https://habr.com/ru/post/983269/


All Articles