Site Loader
angularjs application

Automate Angular JS applications using PROTRACTOR tool JASMINE Framework

Protractor:

  • Protractor is officially known as the “End to End Testing” framework. It is an open source functional automation framework used to test AngularJS/Javascript web applications.
  • Protractor plays an important role in the Testing of AngularJS applications and works as a Solution integrator combining powerful technologies like Selenium, Jasmine, Web driver, etc.
  • Protractor is a Node JS program which is written in JavaScript and runs with Node to identify the web elements in AngularJS applications, and it also uses WebDriver to control the browser with user actions.
  • Protractor uses Jasmine test framework and it is a default framework that comes with the protractor.
  • Protractor allows tests to be organized based on Jasmine, thus allowing us to write both unit and functional tests on Jasmine.

Jasmine Framework :

  • It is a behavior-driven development framework for testing JavaScript code. It is an independent framework having clean and obvious syntax. So, ultimately it helps any end user or non-technical person to write test cases with simple and understandable manner.
  • 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.

How it works

protractor

Prerequisites & Installation:

Prerequisites

Node.js (Latest Version)

  • Download NodeJS
  • Install NodeJs
  • To test Node.Js installation properly open command prompt and execute the command.

Java Development Kit(JDK)

  • Download the JDK
  • Install JDK from

Installation

Install Protractor Globally

  • Open the command prompt and type following command to install protractor globally.

npm install -g protractor

  • This will install two command line tools, protractor and webdriver-manager. Try running below command to check protractor version.

protractor –version

  • The webdriver-manager is a helper tool to easily get an instance of a Selenium Server running. Use it to download the necessary binaries with:

webdriver-manager update

  • now start up a server with:

webdriver-manager start

To Start a Test :

Protractor needs two files to run, a spec file and a configuration file. Save the files .js

A piece of protractor code :

Lets try out with a simple calculator application :

// spec.js
describe(‘Protractor Demo App’, function() {
it(‘should have a title’, function() {
browser.get(‘http://juliemr.github.io/protractor-demo/’);

expect(browser.getTitle()).toEqual(‘Super Calculator’);
});
});

This File contains the logic and locators to interact with the application.

// conf.js
exports.config = {
framework: ‘jasmine’,
seleniumAddress: ‘http://localhost:4444/wd/hub’,
specs: [‘spec.js’]
}

This configuration tells Protractor where your test files (specs) are, and where to talk to your Selenium Server (seleniumAddress). It specifies that we will be using Jasmine for the test framework. It will use the defaults for all other configuration. Chrome is the default browser.

Run using the below command :

Protractor conf.js

Protractor will execute the configuration file with given spec file in it.

Advantages of Protractor:

  • Easy installation and setup.
  • Easily readable Jasmine framework.
  • Supports data-driven test.
  • Includes all advantages of Selenium WebDriver.
  • Auto-synchronization.
  • 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.

Post Author: admin

Leave a Reply

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