i'm trying to run through the tutorial http://angular.github.io/protractor/#/tutorial
when i try to get element using .first()
or .last()
method
the test failed with error:
TypeError Object [object Object] has no method 'indexof'
here is spec.js
var firstNumber = element(by.model('first'));
var secondNumber = element(by.model('second'));
var go = element(by.id('gobutton'));
var latest = element(by.binding('latest'));
var history = element.all(by.repeater('result in memory'));
beforeEach(function() {
browser.get('http://juliemr.github.io/protractor-demo/');
});
//...other tests passed
it('should have a history', function(){
firstNumber.sendKeys(1);
secondNumber.sendKeys(2);
go.click();
expect(history.count()).toEqual(1);
// expect(history.last()).toContain('1 + 2'); //error here
firstNumber.sendKeys(3);
secondNumber.sendKeys(5);
go.click();
expect(history.count()).toEqual(2);
// expect(history.first()).toContain('3 + 5'); //and here
});
regarding to this ElementArrayFinder API it should be run fine
i'm using
You probably meant to expect the element's text instead:
expect(history.last().getText()).toContain('1 + 2');
expect(history.first().getText()).toContain('3 + 5');