I'm a new born QA and I'm trying here to write a Protractor script to select an option from a dropdown. There are 2 options in my dropdown and I'm trying to select it from number.
Here is the code I'm using.
var selectDropdownbyNum = function ( element, optionNum ) {
if (optionNum){
var options = element.findElements(by.tagName('entity.company_id as entity.company_name for entity in entities'))
.then(function(options){
options[1].click();
});
}
};
Option 2 is selected by default when the page loads. What I need is to select option 1 from the dropdown. But, my code doesn't do that.
Here is the code snippet of the select option.
<select required="required" class="form-control empty ng-pristine ng-valid ng-not-empty ng-valid-required ng-touched" name="entity_id" ng-model="invoice.entity_id" ng-options="entity.company_id as entity.company_name for entity in entities" ng-required="true" ng-change="entitySelect(invoice.entity_id)">
<option value="string:568f97841a4885e5de39900e" label="Option Global">Option Global</option>
<option selected="selected" value="string:568f976a1a4885e5de39900d" label="Option Computer Studies">OptionComputer Studies</option>
</select>
Thanks in advance :)