点击针对< A>在NG重复表。量角器E2E测试角 [英] Clicking on <a> in a ng-repeat table. Protractor E2E-test angular

查看:167
本文介绍了点击针对< A>在NG重复表。量角器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>

我想我的E2E copyCalculation特征。所以,首先我想检查我的我的数组长度:

I want to e2e my copyCalculation-feature. So first I want to check my length of my array:

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

在我想preSS在我的表中的第一项,然后检查是否有在M Y数组多一项。

The I'd like to press a the first item in my table and then check if there is one more item in m y array.

我如何在我的表单击第一个项目?

How do I click on the first item in my table?

我想是这样的,但我卡住了。

I tried something like this but I got stuck.

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

一些伪code:

Some pseudo code:

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

鸭preciate任何帮助!

Appreciate any help!

推荐答案

试试这个:

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

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

这篇关于点击针对&lt; A&GT;在NG重复表。量角器E2E测试角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆