example_spec.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. describe('angularjs homepage', function() {
  2. it('should greet the named user', function() {
  3. browser.get('http://www.angularjs.org');
  4. element(by.model('yourName')).sendKeys('Julie');
  5. var greeting = element(by.binding('yourName'));
  6. expect(greeting.getText()).toEqual('Hello Julie!');
  7. });
  8. describe('todo list', function() {
  9. var todoList;
  10. beforeEach(function() {
  11. browser.get('http://www.angularjs.org');
  12. todoList = element.all(by.repeater('todo in todoList.todos'));
  13. });
  14. it('should list todos', function() {
  15. expect(todoList.count()).toEqual(2);
  16. expect(todoList.get(1).getText()).toEqual('build an AngularJS app');
  17. });
  18. it('should add a todo', function() {
  19. var addTodo = element(by.model('todoList.todoText'));
  20. var addButton = element(by.css('[value="add"]'));
  21. addTodo.sendKeys('write a protractor test');
  22. addButton.click();
  23. expect(todoList.count()).toEqual(3);
  24. expect(todoList.get(2).getText()).toEqual('write a protractor test');
  25. });
  26. });
  27. });