I'm trying to select the third option in a dropdown list. Below are some details about the element:
Outer HTML:
<md-option _ngcontent-c6="" role="option" ng-reflect-value="last90Days" tabindex="0" id="md-option-2" aria-selected="false" aria-disabled="false" class="mat-option"><!--bindings={
"ng-reflect-ng-if": "false"
}--> Last 90 Days <!--bindings={
"ng-reflect-ng-if": "true"
}--><div class="mat-option-ripple mat-ripple" md-ripple="" ng-reflect-trigger="[object HTMLElement]"> </div> </md-option>
CSS Selector:
#md-option-37 > div:nth-child(1)
Sorry for the terrible formatting. If anyone has any suggestions about how to select the "Last 90 Days" dropdown item then I'd be very grateful.
Based on what I understand out of your info an the AngularJS
md-select
you need to do the followingFor
element(by.css('selector'));
I always use the shorthand notation, for the rest of the selectors see the docs of Protractor.I would advice to use a better way to wait for the animation to be done. Here I used a
browser.sleep()
, but it's not future proof. You don't want your script to rely on sleeps.Hope it helps.