Markus Ende
Markus Ende

Reputation: 850

Access Angular directive/component instances in Protractor test

I have an Angular application. In Angular unit tests (karma / jasmine) I can access component instances and directives via ComponentFixture / DebugElement.

Is that somehow also possible when running an e2e test via Protractor?

Upvotes: 3

Views: 1366

Answers (1)

Estus Flask
Estus Flask

Reputation: 222513

getDebugNode(domElement) can be used to get debug element inside the application, because it should be imported from @angular/core.

ng.probe(domElement) is global and can be used to get debug element outside the application.

Component instance is available on debug element as debugElement.componentInstance. As for directive instances and other providers, debugElement.injector(SomeClass) can be used to access them, as explained in this answer.

Upvotes: 1

Related Questions