javascript - send keys to element by model in repeater -


following example: protractor element model in repeater array, running head scratcher. want send input value element inside of repeater. simple solution!

my html looks similar this. 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 example, wrote 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 @ "activepost.sendkeys('my post')" following error:

nosuchelementerror: no element found using locator:   by.model("post.subtitle").  stacktrace:          nosuchelementerror: no element found using locator: by.model("post.subtitle")         @ array.foreach (native) error         @ /users/.../e2e/spec.js:51:17         @ array.foreach (native) from: task: asynchronous test function: it() error         @ [object object].<anonymous> (/users/.../e2e/spec.js:32:3)         @ object.<anonymous> (/users/.../e2e/spec.js:2:1) 

would have suggestions try or different way think it? thanks!

answer: error protractor throwing unrelated repeater instead missing ending div tag in view. isn't odd that? go figure.

there no need resolve promises here, chain element , element.all():

var elm = element.all(by.repeater('post in user.posts')).first().element(by.model('post.subtitle')); elm.sendkeys('my post'); 

note i'm using first() here.


note simple by.tagname() locator work here:

var elm = element.all(by.repeater('post in user.posts')).first().element(by.tagname('input')); elm.sendkeys('my post'); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -