微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我有这张桌子

<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()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐