PROTRACTOR: Setting up framework for automation

Read before you proceed further:

  1. Install Nodejs (npm comes by default)
  2. Node -v : checks node version
  3. Npm -version : checks npm version
  4. Install protractor:
    npm install -g protractor (This might throw proxy error as below)
    Error: rollbackFailedOptional: verb npm-session
  5. Setup Proxy(Option 1:Command line):
    npm config list (This will list the current user config in C:/Users/{UserName}/.npmrc file)
    Ex: ; userconfig C:\Users\SESA550640\.npmrc

    npm config rm proxy
    npm config rm https-proxy
    npm config set proxy
    npm config set https-proxy
    npm config set strict-ssl = false
    Npm config set color=false
    npm config set registry (This is Optional)

    Setup Proxy(Option 2: .npmrc File edit):
    Navigate to C:/Users/{UserName}
    Edit .npmrc file
    Replace the content with below:

  6. WebDriver install
    webdriver-manager status ( Will list the status of WebDrivers)

7.webdriver-manager update
It will be installed under below Dir: C:\Users\SESA550640\AppData\Roaming\npm\node_modules\protractor\node_modules\ webdriver-manager

You might get below error due to proxy:
Error: connect ETIMEDOUT
[11:27:15] E/start – Selenium Standalone is not present. Install with webdriver-manager update –standalone

webdriver-manager update –ignore_ssl –proxy ‘’

Now start up a server with:
webdriver-manager start

To verify visit: localhost:4444

To see the sessions :

Write a test
Open a new command line or terminal window and create a clean folder for testing.

Protractor needs two files to run, a spec file and a configuration file.

To begin with we can copy sample example_spec and conf.js from Protractor installation path. When we install protractor these sample files come along with it.


Create a spec file: firstTest_spec.js

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'));

The describe and it syntax is from the Jasmine framework. browser is a global created by Protractor, which is used for browser-level commands such as navigation with browser.get.

create Configuration file: conf.js:

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

Now run the test with ( Assuming that both the spec file and conf file are in same location, else provide the absolute path of spec file in conf file.
specs: [‘Testcases//example.js’]
specs: [‘..//Testcases//JasmineFeatures_spec.js’]
protractor conf.js

If you get below error:
Unable to create new service: ChromeDriverService

Try updating chromedriver :

webdriver-manager update --chromedriver

If you using Visual Studio Code then I recommend installing below plugins:
1- Typescript hero
2- javascript
3- Protractor Test Runner (Enables to run .ts file directly)
4- Since protractor comes with Jasmine out of the box, but if it is installed globally, then VS Code intellisense (code completion) might not work properly. Run below code to enable it.
npm i @types/jasmine
5- Gauge ( for writing better reusable code)
6- Cordova ( AI code completion )

Leave a Reply