Reputation: 44275
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:
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');
});
});
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
Reputation: 44275
Here is a version of todo-spec.js that works:
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
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