1

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

  • jasmine-1.3.1
  • protractor version 1.8.0

1 Answer 1

2

You probably meant to expect the element's text instead:

expect(history.last().getText()).toContain('1 + 2');
expect(history.first().getText()).toContain('3 + 5');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.