'Getting text from angular input elements in Protractor
The angular Input controls doesn't let me get values directly by using getText() in protractor.
<input ng-switch-when="TextBox" ng-if="::!field.uiControlInfo.multiLine" ng-model="field.input[0].value" ng-focus="onFieldFocus(field, 0, $event)" ng-blur="onFieldBlur(field, true, $event)" ng-readonly="field.isReadOnly || state.wait" ng-change="onFieldChange(field, false)" cp-form-view-formatter="field" placeholder="" id="InvoiceNumber" class="cp-flex-fill cp-formview-field-input ng-pristine ng-valid ng-scope ng-touched" ng-style="{ 'text-align': field.uiControlInfo.fieldAlignment.toLowerCase() }" ng-keydown="fieldKeyDown($event, field, 0)" autocomplete="off" style="text-align: left;">
var element=element(By.id());
element.getText().then(function (text) {
console.log(text);
});
This is the ideal way of getting input value from the input elements. But this doesn't work for angular elements.
"angular.element(some_element_id).scope.field.input[0].value"
This gives the value out of the angular elements in browser console.
Can somebody help me with how can i write the same in Protractor??
Solution 1:[1]
Try this
element(by.id('#id')).getText();
Solution 2:[2]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ininiv |
Solution 2 |