Most of us are familiar with the WebDriver (Selenium) which we use to automate the browsers. But being frustrated with all the waits needed for the WebDriver to sync with the app, causing flakes and prolonged test times? then Protractor is a right framework for you.

Protractor is an Open Source, End-to-End test framework specifically built for AngularJS apps. It was built by a team in Google on top of WebDriverJS with existing technologies such as Selenium, Node.js, and Jasmine which makes writing tests a breeze. It’s also a replacement for the existing AngularJS E2E testing framework called Angular Scenario Runner.

Why Protractor AngularJS?

It’s a wrapper around Selenium WebDriverJS and Selenium Server.

Having new locator strategies and functions specifically for Angular apps.

Automatic waiting can execute the next step in your test the moment the web page finishes pending tasks.

Can take the advantage of the Selenium grid to run multiple browsers at once.

Can run test on both real and headless browsers.

Can use Jasmine or Mocha or Cucumber to write your test.

How does Protractor work?

Jasmine helps to create the test.

Protractor helps to run the test.

Selenium Server helps to manage browsers.

Selenium WebDriver helps to invoke browsers APIs.

Advantages of Protractor:

Easy installation and setup.

Easily readable jasmine framework.

Support Data-Driven test.

Include all advantages of Selenium WebDriver.

Auto-Synchronization.

Support parallel testing through multiple browsers.

Excellent speed.

Limitations of Protractor:

Basically, a UI driven testing tool, provide only front-end testing.

No detailed test report, other than test log.

Even though easily understandable framework, need more time to script.

More sensitive and Zero Tolerance.

Hope you are eager to know how to setup protractor and start testing your angular app. Simply follow the steps givenhere to setup the environment.

So you have installed Protractor successfully, right? But we are still not ready to go for a test. Protractor wants two files, to run a test, such as Spec or test file and Config file. Spec file is simply the test file which defines our test cases or suite. The config file is used to define the parameters which will be passed to protractor to execute our Spec file.

All right..! Before going for defining the test, let’s see how to define the config file.

The config file should have the following mandatory parameters:

Selenium server address

Location of spec file

Browser capabilities

Node options

The Spec or test file should be defined using Jasmine framework. The basic structure of test suite should be as follows:

So now we got an idea about the 2 files Spec.js and Conf.js.

conf.js

example-spec.js

Now we are great enough to start our test. We have to move up just 2 more steps to Run the test.