You are on page 1of 10

Protractor

Index-

1. Introduction
2. Setup
3. Sample Test
4. Integration of Protractor with Omnichannel
5. References
Introduction-
Protractor is an end-to-end test framework for AngularJS applications. Protractor
runs tests against the application running in a real browser, interacting with it as a
user would.  ​It is a ​Node.js​ program, and runs end-to-end tests that are also written
in JavaScript and run with node. 

Test Like a User


Protractor is built on top of WebDriverJS, which uses native events and
browser-specific drivers to interact with your application as a user would.

For AngularJS Apps


Protractor supports Angular-specific locator strategies, which allows us to test
Angular-specific elements without any setup effort on your part.

Automatic Waiting
There is no need to add waits and sleeps to tests. Protractor can automatically
execute the next step in test the moment the webpage finishes pending tasks, so we
don’t have to worry about waiting for test and webpage to sync​.
Setup-
Prerequisites:
Note: To successfully install/run prefer latest versions
1. Node.js
2. Java Development Kit (JDK)
3. Git
4. Sublime/Nodepad++ (Any editor which you prefer)
Steps for Installation​:
1.Use npm to install Protractor globally with:
npm install –g protractor
This will install two command line
tools, ​protractor​ and ​webdriver-manager​. The ​webdriver-manager​ is a helper tool to
easily get an instance of a Selenium Server running.

2.Use below command to update binaries of webdriver-manager:


webdriver-manager update
3.To start the selenium webserver
webdriver-manager start
Sample code/script:
Important points to remember:
1. Protractor needs two files to run its tests:
a. Specification file (Spec.js)
b. Configuration file(Conf.js)
2. The conf.js contains selenium server address and path to specification
file(spec.js).
3. Spec.js contains functional logic of script.
Steps to setup a sample script:
1. Create a new folder.
2. Create a conf.js inside new folder created
on step 1.
3. Create a spec.js inside new folder created
on step​ 1.

Snippet of conf.js:
Snippet of spec.js:

To Run a Test-
1. Open GitBash.
2. Write “webdriver-manager start”.
3. Open another GitBash.
4. Write “protractor conf.js”.
Output on console:

Integration of Protractor with Omnichannel:


The test scripts are kept under folder tests​→​functional

The functional folder consists of 4 subfolders and a configuration file in which the
path to the script to be executed is specified.
1. DataRepo​- The folder contains the csv files (comma separated values) that
provides the data needed by the scripts during execution.
Here under data Repo folder we have subfolder according to the
environment present for the system. Each environment has data repos
corresponding to each LOB. For example, for VAN LOB we have
VanDataRepo.csv.

The first column in the dataRepo is of the “TestName” which contains the
test ids of the scripts. The other columns in the dataRepo corresponds to the
fields in the system in which the data according to test scenario is provided.
2. Perf- ​The perf folder has the same csv files which are for capturing the
performance matrix of the
References
1. http://www.protractortest.org/#/
2. https://angular.github.io/protractor/#/
3. https://github.com/angular/protractor
4. https://docs.angularjs.org/guide/e2e-testing

You might also like