Testing angular app with protractor in Visual Studio


Environment prerequisites

Make sure to install these on your machine before you continue:

Setup the tests

Go into the web app directory:

cd .\MyWebApp

Install protractor:

npm install -g protractor

The webdriver-manager is a helper tool to easily get an instance of a Selenium Server running. Use it to download the necessary binaries with:

webdriver-manager update
webdriver-manager start

Create protractor-tests.js and put the following into it:

describe('angularjs homepage todo list', function() {
  it('should add a todo', function() {

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

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

    // You wrote your first test, cross it off the list
    var completedAmount = element.all(by.css('.done-true'));

Create conf.js and paste the followint into it:

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['protractor-tests.js'],
    resultJsonOutputFile: "./result.json",
    multiCapabilities: [

To run your tests create run.bat and execute it:

# make sure to `webdriver-manager start`

protractor %~dp0config.js

22bugs.co © 2017. All rights reserved.