嗨我有关于单选按钮的html。我试图使用by.model获取父元素的子元素列表,并迭代它们并选择单选按钮。我尝试了以下代码但它没有找到任何元素
var drilldownRadios = element(by.model('filterParameters.rptGrping')).$$("md-radio-button");
来自应用的HTML代码
<md-radio-group layout="row" ng-model="filterParameters.rptGrping" class="ng-pristine ng-valid _md layout-row ng-not-empty ng-touched" role="radiogroup" tabindex="0" aria-invalid="false" aria-activedescendant="radio_2722" style="">
<md-radio-button value="National" id="radio_2720" role="radio" aria-checked="false" aria-label="National">
<div class="md-container" md-ink-ripple="" md-ink-ripple-checkbox="">
<div class="md-off"></div>
<div class="md-on"></div>
</div>
<div ng-transclude="" class="md-label">
<filtertext class="ng-scope">National</filtertext>
</div>
</md-radio-button>
<!-- ngIf: !$ctrl.reportInfo.authRoleClasses.studentInfo -->
<md-radio-button ng-if="!$ctrl.reportInfo.authRoleClasses.studentInfo" ng-click="$ctrl.setSelectedStates()" class="stateRadio ng-scope md-checked" value="State" role="radio" tabindex="0" id="radio_2722" aria-checked="true" aria-label="California" style="">
<div class="md-container" md-ink-ripple="" md-ink-ripple-checkbox="">
<div class="md-off"></div>
<div class="md-on"></div>
</div>
<div ng-transclude="" class="md-label">
<filtertext class="ng-binding ng-scope">California</filtertext>
</div>
</md-radio-button>
<!-- end ngIf: !$ctrl.reportInfo.authRoleClasses.studentInfo -->
<!-- ngIf: $ctrl.reportInfo.authRoleClasses.studentInfo -->
<!-- ngIf: !$ctrl.reportInfo.authRoleClasses.studentInfo -->
<md-radio-button value="District" ng-click="$ctrl.setSelectedStates()" ng-if="!$ctrl.reportInfo.authRoleClasses.studentInfo" class="ng-scope" role="radio" tabindex="0" id="radio_2723" aria-checked="false" aria-label="California and District(s)" style="">
<div class="md-container" md-ink-ripple="" md-ink-ripple-checkbox="">
<div class="md-off"></div>
<div class="md-on"></div>
</div>
<div ng-transclude="" class="md-label">
<filtertext class="ng-binding ng-scope">California and District(s)</filtertext>
</div>
</md-radio-button>
<!-- end ngIf: !$ctrl.reportInfo.authRoleClasses.studentInfo -->
</md-radio-group>
答案 0 :(得分:0)
element.all
返回modelfilterParameters.rptGrping
var drilldownRadios = element.all(by.model('filterParameters.rptGrping')).$$("md-radio-button");
drilldownRadios.then(function(arrayElements){
console.log(arrayElements.length);
});