使用量角器从下拉列表中选择一个选项

时间:2018-01-16 10:53:07

标签: javascript angularjs protractor visual-studio-code

  <select _ngcontent-c4="" ng-reflect-is-disabled="false" class="ng-untouched ng-pristine ng-valid">
    <option _ngcontent-c4="" selected="selected" value="People" ng-reflect-value="People">People</option>
    <option _ngcontent-c4="" value="Quality" ng-reflect-value="Quality">Quality</option>
    <option _ngcontent-c4="" value="Profitable Growth" ng-reflect-value="Profitable Growth">Profitable Growth</option>
</select>

我想从下拉列表中找到人员/质量/盈利增长值,然后点击它。 如果有人有相同的指导,请告诉我。 TIA

1 个答案:

答案 0 :(得分:0)

以下代码仅根据您提供的HTML代码:

selectOption(from, option) {
  from.element(by.xpath('./option[.="+option+"]')).click();
}

var from = element(by.css('select.ng-untouched.ng-pristine.ng-valid')));
var option = 'Pepole';

selectOption(from, option);