Reputation: 135
I want to select dropdown option by matching option text.
HTML code:
<li title="Add Page" class="dropdown-header ng-scope" data-ng-if="selectedPage">Add Page</li>
<li title="Add page before the current page" data-ng-if="selectedPage" class="ng-scope">
<a data-ng-click="addPage(selectedPage, 'before')">Before Selected</a> </li>
<li title="Add page after the current page" data-ng-if="selectedPage" class="ng-scope">
<a data-ng-click="addPage(selectedPage, 'after')">After Selected</a></li>
Upvotes: 0
Views: 107
Reputation: 460
I've always used:
.click().sendKeys();
to select options from my drop downs. Haven't had a problem yet.
Upvotes: 0
Reputation: 474001
You can use by.xpath()
and check the a
element's text:
element(by.xpath('//li/a[. = "Before Selected"]')).click();
Or, by link text:
element(by.linkText("Before Selected")).click();
Upvotes: 2