0

I have to track an element from the following element sets which is designed in a dropdown and it should be selected for protractor e2e , appreciate your comments on this,

<option value="5250539" ng-repeat="option in cell.field.selectOptions track by $index" id="5250539" ng-selected="option.id == cell.data.data" class="ng-binding ng-scope">010:sometext </option>

Thanks.

  • Could you show bigger picture of HTML? It's important to see HTML with dropdown also – Oleksii Jul 18 '18 at 05:39
  • These questions are almost the same and should provide you a solution: https://stackoverflow.com/questions/19599450/how-to-select-option-in-drop-down-protractorjs-e2e-tests And https://stackoverflow.com/questions/50266723/dropdown-in-protractor-with-typescript/50910643#50910643 – Silvan Bregy Jul 18 '18 at 07:42
  • 1
    @Oleksii Thanks for replying , it's okey for now I tried the answer bellow and it, worked,@ Silvan thanks for posting the link – Lakmal Rajith Jul 23 '18 at 07:11

1 Answers1

1

Protractor's API Docs give a good example of how you can filter a result set to click a specific result. This is how you'll want to click the single option in the dropdown list.

element.all(by.css('.items li')).filter(function(elem, index) {
  return elem.getText().then(function(text) {
    return text === 'Third';
  });
}).first().click();

Docs available here: https://www.protractortest.org/#/api?view=ElementArrayFinder.prototype.filter

Taran
  • 491
  • 2
  • 8
  • 22