Following this example: Protractor get element by model in repeater array, I am running into a head scratcher. I want to send input value to an element inside of a repeater. Hopefully it is a simple solution!
My HTML looks similar to this. The main difference being "posts" vs "user.posts".
<tr ng-repeat="post in user.posts">
<td ng-click="activePost(post)" class="title">{{post.title}}</td>
<td><button class="btn btn-danger" ng-click="delete(post)">Delete</button></td>
<td><input type="text" ng-model="post.subtitle"
id="{{post.id}}" /></td>
</tr>
Then following the example, I wrote something like this:
element.all(by.repeater('post in user.posts')).then(function(posts) {
var activePost = posts[0].element(by.model('post.subtitle'));
activePost.sendKeys('My post');
});
The protractor test fails at "activePost.sendKeys('My post')" with the following error:
NoSuchElementError: No element found using locator:
by.model("post.subtitle").
Stacktrace:
NoSuchElementError: No element found using locator: by.model("post.subtitle")
at Array.forEach (native) Error
at /Users/.../e2e/spec.js:51:17
at Array.forEach (native) From: Task: Asynchronous test function: it() Error
at [object Object].<anonymous> (/Users/.../e2e/spec.js:32:3)
at Object.<anonymous> (/Users/.../e2e/spec.js:2:1)
Would anyone have any suggestions for what I could try or a different way to think about it? Thanks!
ANSWER: The error Protractor was throwing was completely unrelated to the repeater but instead to a missing ending div tag in the view. Isn't it occasionally something odd like that? Go figure.