10

I'm writing an end to end test using protractor for my application. I'm seeing errors of the form:

No element found using locator: By.model("address.fullName") error. 

The corresponding protractor code which is throwing this error is:

var angularElement = element(By.model("address.fullName"));
angularElement.sendKeys("test");

However I'm able to fetch this element using:

var angularElement = element(By.xpath('//input[@ng-model="address.fullName"]'));

HTML snippet:

input ng-model="address.fullName" type="text" class="control-input ng-pristine ng-invalid ng-invalid-required" size="40" name="fullName" ng-class="{ 'required-field': isInformationSubmitted }" required=""

I'm not sure why this is happening. Any ideas?

user3512851
  • 99
  • 1
  • 6
  • Can you put a snippet of the view? How does the HTML looks like? – Andres D Apr 09 '14 at 17:33
  • 1
    Internally, I think the `By.model` locator relies on the element having the `ng-binding` class applied to it. This class is supposed to be applied automatically by angular, but I've seen instances where it didn't happen ([example](https://github.com/angular/protractor/issues/157)). Check if the element you're trying to locate has the `ng-binding` class or not. If not... I would *not* recommend putting it in yourself, but rather simply switching to a different locator (xpath or css) until the underlying issue in angular is fixed. – Lukas S. Apr 13 '14 at 04:27

1 Answers1

4

I've had some close errors, my error occurred cause the item was not shown on the page or protractor did not finish updating its model so before using the variable i:
-maximized the page: If the element was unseen browser.manage().window().maximize();
-opened the list the item was in:
-waiting for protractor to finish updating it's model:

var ptor = protractor.getInstance();
ptor.waitForAngular();
Avishay
  • 305
  • 1
  • 11
  • 2
    Since 1.5.0 it would be `browser.waitForAngular` - https://angular.github.io/protractor/#/api?view=Protractor.prototype.waitForAngular – Jade Hamel Apr 05 '16 at 19:36