Protractor Tutorial 4 – Introduction To Protractor Test Tool & How It Works

As per official document of Protractor:-

Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would.

Three major points about Protractor are:-

  1. Protractor is built on top of WebDriverJS, which uses native events and browser-specific drivers to interact with your application as a user would.
  2. Protractor supports Angular-specific locator strategies, which allows you to test Angular-specific elements without any setup effort on your part.
  3. You no longer need to add waits and sleeps to your test. Protractor can automatically execute the next step in your test the moment the webpage finishes pending tasks, so you don’t have to worry about waiting for your test and webpage to sync.

Protractor is a NodeJS program. So you must have NodeJS installed in your system. It supports Jasmine, Mocha and Cucumber test frameworks.

How Protractor Works?

As per Protractor official documents:-

When working with Protractor, it’s important to keep the following in mind:

  • Protractor is a wrapper around WebDriverJS, the JavaScript bindings for the Selenium WebDriver API.
  • WebDriver commands are asynchronous. They are scheduled on a control flow and return promises, not primitive values.
  • Your test scripts send commands to the Selenium Server, which in turn communicates with the browser driver.

Process Communications:-

A test using Selenium WebDriver involves three processes – the test script, the server, and the browser. The communication between these processes is shown in the diagram below.

The Selenium Server takes care of interpreting commands from the test and forwarding them to one or more browsers. Communication between the server and the browser uses the WebDriver Wire Protocol, a JSON protocol. The command is interpreted by the Browser Driver.

With Protractor, the test script is run using Node.js. Protractor runs an extra command before performing any action on the browser to ensure that the application being tested has stabilized. For example, let’s look at the following snippet of test code.


This will result in three commands being sent to the Browser Driver

  • /session/:sessionId/execute_async – First, Protractor tells the browser to run a snippet of JavaScript. This is a custom command which asks Angular to respond when the application is done with all timeouts and asynchronous requests, and ready for the test to resume. This is actually automate wait or sync of Protractor for Angular applications.
  • /session/:sessionId/element – Then, the command to find the element is sent.
  • /session/:sessionId/element/:id/click – Finally the command to perform a click action is sent.


More on Protractor in upcoming posts. Stay tuned and keep learning with me.


1 thought on “Protractor Tutorial 4 – Introduction To Protractor Test Tool & How It Works

Leave a Reply

Your email address will not be published. Required fields are marked *