从下拉列表中选择值

问题描述 投票:1回答:3

我的代码是

<md-option ng-repeat="item in countryList" ng-value="item" tabindex="0" class="ng-scope md-ink-ripple" role="option" aria-selected="false" id="select_option_778" value="[object Object]" style="">
 <div class="md-text ng-binding">Afghanistan</div>
 <div class="md-ripple-container" style=""></div>
</md-option>"

这是一个下拉列表。请帮我用量角器逐个选择所有国家。

我试过这个

 element.all(by.repeater("item in countryList").row('1')).click();
angularjs drop-down-menu protractor
3个回答
-1
投票

试试这个,这应该有效。

 var countryList = element.all(by.repeater('item in countryList'));

    for (i=0; i<=countryList.length(); i++)
    {
             countryList.get(i).click();
    }

-1
投票

尝试将countryList.count()用于element.all数组


-1
投票

你可以尝试以下方式

var deferred = protractor.promise.defer();'
var selectAllElement = [];
var countryList = element.all(by.repeater('item in countryList'));

    for (i=0; i<=countryList.length(); i++)
    {
             selectAllElement.push(countryList.get(i).click());
    }
    return protractor.promise.all(selectAllElement)

无论您在何处使用此代码,请使用.then(以及下一步操作。如果有任何问题,请告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.