2

I have a repeater like this

<div ng-repeat="d in data">
    <input type="checkbox" ng-mode="d.checked" name="someName" />
    <span>{{d.name}}</span>
</div>

I want to get the input:checkbox for the row where span contains text 'test5' i.e. for which span is bound to d.name == 'test5'

coure2011
  • 40,286
  • 83
  • 216
  • 349
  • Wouldn't you be able to select that using either CSS selectors or JavaScript once the repeater is bound? Examples here: http://stackoverflow.com/questions/13471129/ng-repeat-finish-event – Ted Nyberg Sep 17 '15 at 07:08
  • Did you try using the xpath as this - `//input[preceding-sibling::span[contains(.,'test5')]]` ? – giri-sh Sep 17 '15 at 07:32

1 Answers1

2

Here is how I solved it

var allO = element.all(by.repeater('o in Types').column('o.name'));
allO.filter(function(elem, index) {
    return elem.getText().then(function(text) {
        return text === 'test5';
    });
}).then(function(sSpan) {
    var parent = oSpan[0].element(by.xpath('..'));
    parent.element(by.css('input')).click();
    browser.waitForAngular();
});
FarazShuja
  • 2,287
  • 2
  • 23
  • 34