There's quite a few ways to do this and I've tried a good number of them but I can't select an item from a drop down menu when doing an automated test.
"Select" is the default choice that appears in the drop down menu, I want the automated test to pick one of the elements, doesn't matter which one
This is the HTML Code
<select class="form-control ng-pristine ng-invalid ng-invalid-required" ng-model="user.investmentAmount" required="" ng-class="{submitted:invalid}">
<option value="">Select</option>
<option value="<50"> 50K</option>
<option value="50-100">100K</option>
<option value="100-250">250K</option>
<option value="250-500">500K</option>
</select>
And this is my Protractor file
var selectDropdownbyNum = function ( element, optionNum ) {
if (optionNum){
var options = element(by.cssContainingText("Select"))
.then(function(options){
options[2].click();
});
}
};
browser.sleep(2000);
I've tried using by.cssElement, by.xpath etc. When I run the above, I get no errors but it doesn't select any element either. Thanks