P.Brian.Mackey
P.Brian.Mackey

Reputation: 44275

Protractor setup example is not working

I am running the example posted on github for protractor. When I run the example I get error:

NoSuchElementError: No element found using locator: by.model("todoText")

I am using the same settings listed on the website:

todo-spec.js:

describe('angularjs homepage todo list', function() {
  it('should add a todo', function() {
    browser.get('http://www.angularjs.org');

    element(by.model('todoText')).sendKeys('write a protractor test');
    element(by.css('[value="add"]')).click();

    var todoList = element.all(by.repeater('todo in todos'));
    expect(todoList.count()).toEqual(3);
    expect(todoList.get(2).getText()).toEqual('write a protractor test');
  });
});

conf.js

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['test/e2e/app/todo-spec.js']
};

I tried changing the value to todoList. This also failed.

Upvotes: 0

Views: 523

Answers (2)

P.Brian.Mackey
P.Brian.Mackey

Reputation: 44275

Here is a version of todo-spec.js that works:

todo-spec.js

describe('angularjs homepage todo list', function() {
  it('should add a todo', function() {
    browser.get('http://www.angularjs.org');

    element(by.model('todoList.todoText')).sendKeys('write a protractor test');//correction
    element(by.css('[value="add"]')).click();

    var todoList = element.all(by.repeater('todo in todoList.todos'));//correction
    expect(todoList.count()).toEqual(3);
    expect(todoList.get(2).getText()).toEqual('write a protractor test');
  });
});

Upvotes: 0

Arthur Frankel
Arthur Frankel

Reputation: 4705

Looks like the value for ng-model is todoList.todoText on the angular website so...

element(by.model('todoList.todoText')).sendKeys('write a protractor test');

and probably

var todoList = element.all(by.repeater('todo in todoList.todos'));

Upvotes: 3

Related Questions