Introduction to Protractor

Profile picture for user ksharma

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.

Key points about Protractor

  • Protractor is an open source Node.js program and end-to-end framework developed by Google.
  • It also serves as a replacement for the existing AngularJS E2E testing framework called “Angular Scenario Runner”.
  • Protractor is built on top of WebDriverJS, which uses native events and browser-specific drivers to interact with your application as a user would.
  • Protractor supports Angular-specific locator strategies, which allows you to test Angular-specific elements without any setup effort on your part.
  • 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.
  • It also works as a solution integrator that combines powerful technologies such as NodeJS, Selenium, Jasmine, WebDriver, Cucumber, Mocha etc. 

Why Protractor?

  1. JavaScript: JavaScript is a language widely used in web applications. And that makes sense since it has virtually no competitor. JavaScript started as an amazingly simple scripting language. Most application are using Angular now.
  2. Selenium Limitations: Protractor has a number of advantages over using pure Selenium. First, since it’s a Node app, Protractor benefits from the huge number of packages available through Node. AngularJS applications are having some extended HTML attributes like ng-repeater, ng-controller and ng-model etc. which are not included in Selenium locators.
  3. Automatic Waiting: One of the biggest advantages of Protractor is automatic waiting. With Protractor, there’s no need to add sleeps and waits to your tests when you need to wait for elements on a page. Protractor executes the next step as soon as a page finishes its pending tasks. As a consequence, Protractor makes your tests quicker since it reduces sleep and wait times.