What is Protractor?
Protractor is an end-to-end test framework for AngularJS applications. Protractor runs tests against your application in a real/actual browser, interacting with it as a real browser. Protractor can also be defined as a solution integrator – combining powerful tools and technologies such as NodeJS, Selenium, webDriver, Jasmine, Cucumber and Mocha.
By default, Protractor uses the Jasmine test framework for its testing interface. This tutorial assumes some familiarity with Jasmine, and we will use version 2.4.Protractor which has a bunch of customization from Selenium to easily create tests for AngularJS applications.
Protractor speeds up your testing as it avoids the need for a lot of “sleeps” and “waits” in your tests, as it optimizes sleep and wait times. As it is based on AngularJS concepts, it makes it easy to learn Protractor if you already know about AngularJS and vice versa.
Protractor allows tests to be organized based on Jasmine, thus allowing you to write both unit and functional tests on Jasmine. It runs on real browsers such as Chrome, Firefox, IE and Safari and headless browsers run tests using GhostDriver, for which you need to use PhantomJS which uses GhostDriver to run tests in Headless mode .
Protractor is a framework for automation of end-to-end functional tests, so its intention isn’t to be the only way to test an AngularJS application, but to cover the acceptance criteria required by the user. Even if there are tests that run in the UI level with Protractor, unit and integration tests are still needed. It runs on top of the Selenium, and thus provides all the benefits and advantages of Selenium.
The framework integrated with Jasmine can be used to create and organize tests and user expectations. Jasmine is compatible with Protractor due to which all resources that are extracted from browsers can be used to make tests as promises. Those promises are resolved internally by using the “expect” command from Jasmine. That way the promises work smoothly while creating tests.
Work Flow Diagram
Advantages of Protractor:
- Easy installation and setup.
- Easily readable Jasmine framework.
- Supports data-driven test.
- Includes all advantages of Selenium WebDriver.
- Supports parallel testing through multiple browsers.
- Excellent speed.
Limitations of Protractor:
- Basically, a UI driven testing tool that provides 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.