从中继器量角器提取数据(Protractor extract data from a repeate

2019-10-19 07:33发布

用量角器开始测试角JS应用程序,我想我的提取应用程序的搜索结果。

要做到这一点,我需要通过一个中继器“在对象的对象”进行迭代并提取名称coloumn:

我使用此代码:

var result = element.all(by.repeater('object in objects').column('name'))

result.then(function(arr) {

 //Traverse the repeater and extract data

for (var i = 0; i < arr.length; ++i) {

    arr[i].getText().then(function(text) {
        console.log( text);
       console.log( arr.length);
    });
}

此代码只显示即使我的检索算法的结果是远远6第6个要素。

输出:

TSK(AGR020J)(000)(AGR020JN00)(000)
40

40
TSK(ASA700J)(000)(ASA700JU00)(000)
40

40
TSK(AGR060J)(000)(AGR060JN00)(000)
40

40
TSK(AGT001H)(000)(AGT001HS20)(000)
40

40
TSK(ANF010J)(000)(ANF010JU00)(000)
40

40
TSK(AGT001H)(000)(AGT001HN20)(000)
40

40


40

40
 ....

6是我的结果的第一行中的元素个数,我不”知道为什么搜索doese不包括剩余的行?

这里是HTML temlate:

<div id="jobHolder" class="thumbJobs" style="height: 326px; overflow: hidden;"                           tabindex="5027">
<div id="job_1" class="job ng-scope" ng-click="showJobHoverInfo($index+1)" ng-repeat=
"object in objects" ng-class="object.jobStyle">
  <div id="job_1_viewerEye" class="viewerEye" ng-click=
  "viewerEye($event,$index+1, object)" ng-class="object.viewerEyeClass"></div>

  <div id="job_1_jobBigPicto" class="jobBigPicto transition_2_opa">
    <div id="job_1_jobsSmallPictos" class="jobsSmallPictos transition_2_opa">
      <div id="job_1_jobDown" class="jobDown transition_2_opa">
        <div id="job_1_jobHoverInfo" class="jobHoverInfo" ng-click=
        "hideJobHoverInfo($event,$index+1)" style="left: -100%; top: 272px;"></div>

        <div id="job_2" class="job ng-scope" ng-click="showJobHoverInfo($index+1)"
        ng-repeat="object in objects" ng-class="object.jobStyle">
          <div id="job_2_viewerEye" class="viewerEye" ng-click=
          "viewerEye($event,$index+1, object)" ng-class="object.viewerEyeClass">
          </div>

          <div id="job_2_jobBigPicto" class="jobBigPicto transition_2_opa">
            <div id="job_2_jobsSmallPictos" class="jobsSmallPictos transition_2_opa">
              <div id="job_2_jobDown" class="jobDown transition_2_opa">
                <div id="job_2_jobHoverInfo" class="jobHoverInfo" ng-click=
                "hideJobHoverInfo($event,$index+1)" style="left: -100%; top: 272px;">
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</div>
   </body>
</html>

对不起,我想我已经贴了错误的HTML,你可以修改后,现在看到了:NG-重复=“对象中的对象”

文章来源: Protractor extract data from a repeater