1. Introduction
This document describes how we can create a
test suite in protractor which can test AngularJS web application UI e2e. It will test
the user interface of the application.
2. Tools
WebStorm IDE
Protractor binary
Jasmine Reporters
Selenium WebdriverJS Standalone server
SauceLabs
3. Installation
·
Install Node.js on your machine
·
Open a command prompt and type following
>npm install -g protractor
To
install selenium webdriver type following
>webdriver-manager update
Start the server with
>webdriver-manager start
4. Framework

E2e test will be written in js files using
page object model i.e. objects of a web page will be separate and kept in
separate js files
Actual test will call these page objects
and use the methods like click (), getText () etc.
Reports will be generated in xml format.

Test data will be created tested and detroyed
using beforeEach() and AfterEach() methods for each and every tests.
SauceLabs may be used to run test remotely using
the following:

5.
Example
Page Object
var AngularHomepage = function() {
this.nameInput = element(by.model('yourName'));
this.greeting = element(by.binding('yourName'));
this.get = function() {
browser.get('http://www.angularjs.org');
};
this.setName = function(name) {
this.nameInput.sendKeys(name);
};
};
Actual Test
describe('angularjs homepage', function() {
it('should greet the named user', function() {
var angularHomepage = new AngularHomepage();
angularHomepage.get();
angularHomepage.setName('Julie');
expect(angularHomepage.greeting.getText()).toEqual('Hello Julie!');
});
});
To run the test use following:
>protractor protractor.conf.js
6. Test Cases
1) Login_Test.
- Enter the URL
: http://172.18.122.88:8080/AVS-angular/#/
- Enter the User
name and Password.
- Click on Login.
(A new webpage will appear.)
- Click on “Role
Management”.
- Click on “Create”.
- Enter “Role
Name” and “Description” in the corresponding Edit Boxes.
- Click on save
button.
2) Signup_Test
- Enter the URL
: http://172.18.122.88:8080/AVS-angular/#/
- Enter the User
name and Password.
- Click on “Sign
Up here” Link. (A new webpage will appear.)
- Enter Email,
First Name, Middle Name, Last name and mobile number in the corresponding
edit boxes.
- Click on Sign
Up.
3) Details_Test
- Enter the URL
: http://172.18.122.88:8080/AVS-angular/#/
- Enter the User
name and Password.
- Click on Login.
(A new webpage will appear.)
- Click on Company
Management.
- Click on
Registor.
- Enter Company
Name, Company City, Email, and Phone.
- Select Country
and Company Type
- Enter values the
Edit boxes.
- Click on save.
- Click on Company
Management
- Click on Manage.
7. Parameterization
Parameterization can be achieved by using CSV parser.
8. Pros and Cons
Pros:
- Open Source
- Support for Angular JS.
Cons:
- Debugging is hard.
- Framework and parameterization is also
difficult.
- Recording is not possible.
- Very less support is available.
- Mobile device support is also not available.
9. References
Wow this is really amazing post. Thanks for sharing the useful informative data. I appreciate your difficulty work. Keep blogging. Protractor Training in Electronic City
ReplyDelete