AngularJS 嵌套中的量角器测试 ng-repeat

AngularJS protractor test in nested ng-repeat

我是这样嵌套的 ng-repeat。我正在做量角器测试。所以我想访问 parent 转发器的第一个索引。

   <div ng-repeat="pChild in mainParent | orderBy : 'order'" ng-show="checkfor.qm">
        <div  ng-repeat="cChild in Child ">
<input id="checkbox-01" type="checkbox" class="ng-valid ng-dirty ng-valid-parse ng-touched ng-not-empty">
        </div>
    </div>

所以,我想 select 首先 child of mainParent 并在其中计算 Child 的长度。 我是量角器测试的新手。请帮我。提前致谢

我假设您想计算 mainParent 的第一个 child 的 cChild 的长度。您可以使用以下代码。

<div ng-repeat="pChild in mainParent| orderBy : 'order'" ng-show="checkfor.qm" ng-init="parentIndex = $index">
    <div ng-repeat="cChild in pChild| orderBy:'iseeit__Priority__c' ">
       <span ng-if="parentIndex === 0">cChild.length<span>
    </div>
</div>

用一些局部变量实例化 parent 索引,并检查它是否是第一个元素。

如果您正在寻找其他东西,请告诉我。

var elm = element(by.repeater("pChild in mainParent").row(0)).all(by.repeater("cChild in Child")).map(function (elm) {
            return elm.element(by.css("input#checkbox-01")).getAttribute("class");
        }).then(function (links) {
            console.log(links.length);
          })

links.length提供了长度。