Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 e2e using protractor: by.model not working

While writing test cases using protractor.js for Angular 2 application , if I want to get element(by.model("xyz.test")) its always giving failure saying angular is not defined.

Any idea how to fix this issue?

like image 477
Snehasis Mohapatra Avatar asked Jun 28 '16 13:06

Snehasis Mohapatra


2 Answers

As mentioned by @Carmen Popoviciu, who is one of the contributors to the Protractor style guide, by.model and by.binding are not yet working with Protractor and Angular 2:

"Keep in mind that currently not all locator strategies are supported for ng2 apps. Things like by.model() or by.binding() are not working just yet. Check the Protractor changelog for new releases"

https://github.com/CarmenPopoviciu/angular2-go-protractor

like image 108
Gabriel Kohen Avatar answered Oct 19 '22 11:10

Gabriel Kohen


The answer from @Gabriel Kohen is definitely accurate but I thought I would add another answer with some links to the documentation that actively discourage use of by.model and by.binding

https://github.com/angular/protractor#compatibility

https://github.com/angular/protractor/blob/master/docs/locators.md#locators

At this point it's probably unlikely they will ever be supported.

like image 42
cliff.meyers Avatar answered Oct 19 '22 13:10

cliff.meyers