How can we help?


Automation with the ‘Robust’ Tool: Protractor

Naveen Gautam Naveen Gautam July 2, 2018
QA-Protractor - Banner

We at Intelegencia get many questions on Automation. Technology companies are curious to know about the most suitable tools to automate. Manual effort consumes a lot of time and energy and mundane tasks become very tiresome. This is where automation helps.

Automating testing frameworks helps you improve the quality, speed and accuracy of your testing processes. The strategy to adopt test automation should clearly define when to opt for automation, its scope and selection of the right kind of tools for execution.

Protractor, as per our experience at Intelegencia, is one such automation tool. Given below are details about Protractor, its salient features, advantages and it being preferred over others for automation.

What is Protractor?

Protractor is an automation-testing tool for web applications testing which combines powerful technologies such as Jasmine, Selenium Web driver and Node.js. Used mostly on Angular applications, Protractor helps overcome shortcomings arising out of using selenium and other automation tools.

Salient features of Protractor:

  • It has been built on top of WebDriverJS and Selenium server
  • It introduces end users to simpler syntax to write tests
  • It facilitates running tests that target remote addresses
  • Protractor is a wrapper around WebDriverJS and supports behavior-driven development frameworks like Jasmine, Mocha, Cucumber etc.
  • It offers new locator strategies and functions that automate the testing of AngularJS applications. Protractor works in conjunction with Selenium to offer an automated test infrastructure.
  • It makes use of the Selenium grid to run multiple browsers at once.

Framework that accounts for end-to-end testing:

It supports two behaviour-driven development (BDD) test frameworks right out of the box:

  • Jasmine: Jasmine is the default test framework when testing teams install Protractor. Jasmine will be the point of reference in this piece.
  • Mocha: Mocha is a JavaScript test framework running on Node.js. If you wish to use Mocha as your test framework, you will have to set it up with Protractor. Moreover, you will also need to use a Behaviour Driven Development interface and Chai Assertions with Chai as promised (refer to this link for more details). It also supports test framework Cucumber.

Advantages of Protractor:

  • No need to add waits and sleeps: As the webpage finishes pending tasks, Protractor executes the following steps of the testing process by automatically connecting with the AngularJS application.
  • Page Object: Protractor makes it easy to set up page objects. It does not perform WebDriver commands until an action is needed, i.e., set up page objects so that tests can operate with page elements without moving the HTML.
  • Angular-specific locator support: Protractor supports Angular-specific locator strategies including binding, model and repeater as well as native WebDriver locator strategies.

Why is Protractor preferred over Selenium for automating Angular Web applications?

Protractor wraps around WebDriverJS, the latter having JavaScript Selenium bindings. In other words, Protractor interacts with a browser through the Selenium WebDriver. It provides a highly convenient API and has some unique Angular-specific features. These include Angular specific element locating strategies (by. Model()by. Binding()by. Repeater()); automatic synchronization between Protractor and Angular to minimize the use of explicit waits; built-in support of Browser Stack and Sauce Labs; test parallelization and many more.

Another advantage of transitioning to Protractor/JavaScript is that both the application and the test codebase are written in the Same Language.

Given below are some common challenges Protractor helps resolve easily:

  • Understanding asynchronous test execution in general
  • Promises and Control Flow: When to resolve a promise and when not to; how to pass promises around from function to function; when to use deferred and how to manually fulfil/reject a promise; using done() in Jasmine
  • Tackling flaky end-to-end tests
  • Test code design and organization - Where and how to keep page objects, how to wrap page objects into each other

Protractor acts as an end-to-end testing framework for both Angular and non-Angular applications that do not use CSS attributes. Automating web applications built on AngularJS using Protractor is a major step forward for enterprises in their efforts to automate business process applications.

Naveen Gautam is a QA-Lead at Intelegencia.


_BlogComment.Name Html.Raw(_BlogComment.PostedOn.ToString("MMMM d, yyyy"))


Leave your comment

Get Started Now

Future-proof your brand with Intelegencia. Fill out the form and we'll be in touch soon.