I need to select the textbox created by ng-repeat and send some values using sendKeys Function. But I'am not sure about the method to select the textboxes. Please suggest a method to accomplish this Or Should I use css selectors instead.
<div class="qst_input_hld ng-scope" ng-repeat="option in options track by $index">
<input type="text" class="input-sm ng-pristine ng-valid" ng-model="options[$index]" placeholder="Option 1" ng-class="isOptionEmpty[$index] ? 'error-border' : ''">
<!-- ngIf: $index > 1 -->
</div>
There are multiple ways to locate the text input and, since there is a repeater there, I suspect there are multiple text boxes. Assuming you want to send keys to the first one, here is one option:
Note that you don't need to handle the
track by
part at all - it is getting stripped away by Protractor (source code reference).Also note that I've just used the
by.tagName()
technique which may or may not work depending on if you have the otherinput
elements there. You can be more strict and use a CSS selector instead, e.g. check the placeholder:And, if you want to send keys to input element for every item in the repeater, use
each()
:Provide a name and id attribute to your text boxes :
And if you want to select all textboxes :
Specific textbox :
Through Protractor : First change the ng-model of your input box to :
Then select it by using model :