加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 在ng-repeat表中单击.量角器E2E测试角度

发布时间:2020-12-17 06:54:27 所属栏目:安全 来源:网络整理
导读:我有这张桌子 table class="table" thead tr th class="col-sm-5"Actions/th th class="col-sm-5"Title/th th class="col-sm-2"Saved/th /tr /thead tbody tr ng-repeat="calc in calculations" td a class="btn btn-default btn-sm" ng-click="removeCalcul
我有这张桌子

<table class="table">
      <thead>
      <tr>
        <th class="col-sm-5">Actions</th>
        <th class="col-sm-5">Title</th>
        <th class="col-sm-2">Saved</th>
      </tr>
      </thead>
      <tbody>
      <tr ng-repeat="calc in calculations">
        <td>
          <a class="btn btn-default btn-sm" ng-click="removeCalculation(calc.calcId)">
            <i class="fa fa-trash-o"></i>
          </a>
          <a class="btn btn-default btn-sm" href="#">
            <i class="fa fa-bar-chart-o"></i>
          </a>
          <a class="btn btn-default btn-sm" ng-href="#/user/{{user.userId}}/calculation/{{calc._id}}">
            <i class="fa fa-folder-o"></i>
          </a>
          <a id="copyCalcButton" class="btn btn-default btn-sm" ng-click="copyCalculation(calc.calcId)">
            <i class="fa fa-copy"></i>
          </a>
        </td>
        <td>{{calc.title}}</td>
        <td>{{calc.savedAt}}</td>
      </tr>
      </tbody>
    </table>

我想要我的copyCalculation功能.首先,我想检查一下我的数组长度:

var nrOfCalc =  browser.element.all(by.repeater('calc in calculations')).count();

我想按下表格中的第一项,然后检查m y数组中是否还有一项.

如何点击表格中的第一项?

我试过这样的事情但是我被卡住了.

var firstRowIn;
browser.findElements(protractor.By.tagName('tr')).then(function(rows){
  firstRow = rows[0];
});

一些伪代码:

firstRow...click('on the id="copyCalc")

感谢任何帮助!

解决方法

试试这个:

element(by.repeater('calc in calculations').row(0)).$('#copyCalc').click()

要么

element(by.repeater('calc in calculations').row(0)).element(by.css('#copyCalc')).click()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读