Reputation: 1906
HTML:
<div ng-repeat="todo in todos">
<span><input ng-model="todo.title" /></span>
<span><input ng-model="todo.time" /></span>
<span><input ng-model="todo.name" /></span>
</div>
Passing test:
expect(element(by.repeater('todo in todos')).isPresent()).toBe(true);
Passing test:
expect(element(by.repeater('todo in todos').row(1)).isPresent()).toBe(true);
Failing test 1:
Expected false to be true.
expect(element(by.repeater('todo in todos').row(1).column('todo.name')).isPresent()).toBe(true);
Failed test 2:
Expected false to be true.
browser.isElementPresent(element(by.repeater('todo in todos').row(1).column('todo.name'))).then(function(present){
expect(present).toBe(true);
})
At item level I can set data in field. At item level I can retrieve data in field. But not able to use isPresent
or isElementPresent
at item level?
Upvotes: 1
Views: 620
Reputation: 1906
Got it Working ! This code will sendKeys
only if input is present.
I debugged this Code in webstorm and did this:
element.all(by.repeater('todo in todos')).then(function(allrows){
for(var i = 0 ;i<allrows.length ;i++)
{
allrows[i].all(by.model('todo.name')).then(function(field){
field[0].isPresent().then(function(val){
expect(val).toBe(true);
field[0].sendKeys('22.335');
});
});
}
});
Upvotes: 1
Reputation: 473833
The problem here is that .column('todo.name')
would search for elements bound to todo.name
. In other words, it would make a search by binding (see findRepeaterElement
), while you have todo.name
defined as an ng-model
.
Quoting @juliemr (issue ng-repeat with ng-model bindings):
the column selector takes a string which matches bindings, not input ng-models.
Upvotes: 2