I am trying to select an option "India" from a drop down for the angular e2e tests using protractor.
Here is the code snippet of the select option:
<select id="countryCode" class="form-control nux-select input-md ng-touched ng-dirty ng-valid-parse ng-valid ng-valid-required" required="" data-ng-model="selectedCountry" data-ng-options="c.country for c in country" name="countryCode">
<option class="" selected="" value="">-- select --</option>
<option value="0">Afghanistan</option>
<option value="1">Albania</option>
.
.
.
<option value="29">Brazil</option>
<option value="30">British Indian Ocean Territory</option>
.
.
.
<option value="98">India</option>
<option value="99">Indonesia</option>
I have tried:
element(by.cssContainingText('option', 'India')).click();
But as "British Indian Ocean Territory" option is coming before it is selecting this option instead of "India".
so i tried as below and it works:
element(by.xpath('//select[@id="countryCode"]/option[98]')).click();
but as i'm hard coding and new values may be added into the drop-down can anyone suggest me different way to achieve it.