如何在量角器中获取中继器内的绑定文本

How to get the text of a binding inside a repeater in Protractor

使用这个 example web,我怎样才能用 Protractor 得到 {{result.first}} 的值?那个在中继器里面,所以我不能通过绑定访问它。

这是我要使用该值的示例。

<div ng-controller="CalcCtrl" class="container">
    <div>
      <h3>Super Calculator</h3>
      <form class="form-inline">
        <input ng-model="first" type="text" class="input-small"/>
        <select ng-model="operator" class="span1"
                ng-options="value for (key, value) in operators">
        </select>
        <input ng-model="second" type="text" class="input-small"/>
        <button ng-click="doAddition()" id="gobutton" class="btn">Go!</button>
        <h2>{{latest}}</h2>
      </form>
    </div>
    <h4>History</h4>
    <table class="table">
      <thead><tr>
        <th>Time</th>
        <th>Expression</th>
        <th>Result</th>
      </tr></thead>
      <tr ng-repeat="result in memory">
        <td>
          {{result.timestamp | date:'mediumTime'}}
        </td>
        <td>
          <span>{{result.first}}</span>
          <span>{{result.operator}}</span>
          <span>{{result.second}}</span>
        </td>
        <td>{{result.value}}</td>
      </tr>
    </table>
</div>

这是量角器代码:

describe('Protractor Demo App', function() {
  var firstNumber = element(by.model('first'));
  var secondNumber = element(by.model('second'));
  var goButton = element(by.id('gobutton'));
  var latestResult = element(by.binding('latest'));
  var history = element.all(by.repeater('result in memory'));

  function add(a, b) {
    firstNumber.sendKeys(a);
    secondNumber.sendKeys(b);
    goButton.click();
  }

  beforeEach(function() {
    browser.get('http://juliemr.github.io/protractor-demo/');
  });

  it('should have a history', function() {
    add(1, 2);
    add(3, 4);

    expect(history.count()).toEqual(2);
  });
});

API for protractor, and about repeaters

中阅读更多内容
element.all(by.repeater('result in results')).first()
element.all(by.repeater('result in results')).get(0)

两者都将 return 第一个结果,对于其中的每个元素,将其与 element.all(by.repeater('result in results')).first().element...

链接起来