1
votes

I start to use Protractor from few days. But by.repeater function seems to show pass test for every ng-repeat element even though that binding name is wrong. here is the examples gives in protractor tutorial page http://angular.github.io/protractor/#/tutorial

 // spec.js
describe('angularjs homepage', 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);

    add(5, 6);

    expect(history.count()).toEqual(3); // This is wrong!
  });
});

but even though I change the code it gives test pass

 // spec.js
describe('angularjs homepage', 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 me'));

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

    add(5, 6);

    expect(history.count()).toEqual(3); // This is wrong!
  });
});

I don't know whether I am trying to use it

1

1 Answers

0
votes

I found the answer. it is a bug in Protractor. The problem is Protractor check whether

result in me

is in (with indexOf command) a string with ng-repeat but not check whether it is equal to it.

So it pass the test cases with "result in me" , "result in memory" but not "result in memorys"

I think it has to be fixed