A Sample Page Object Model using Protractor
Table of Contents generated with DocToc
The above github repository contains a simple scenario of using Page Object Model(POM) in protractor tests. Page Object Model is on of the various good testing practises that allows us to have better maintainibility and resuability of the code use. You can read more about POM here.
We will use simple test to add a new todo task in the angular website homepage. This tutorial was originally created here. All credits goes to Mallory Mooney for this simple example.
The tests have been written with the pre-condition that the system used for testing has the following installed
* node.js
* node package manager (npm)
* protractor - latest version - please see the link here for latest version information.
* webdriver-manager - this needs to be updated to latest version.
If you need information on how to install node.js
or protractor
, you can refer to my earlier github post and use the information for there.
There are three tests that are included in the files above -
The test contains three files -
You will notice that in the prot-todoconf.js
file, there is a jasmine-spec-reporter
used in. This is a JS library for displaying the protractor in a formatted way. You can refer to this link for information regarding how to add this to your protractor tests.
You can simply run these tests by running the protractor prot-todoconf.js
file from your command prompt.
protractor prot-todoconf.js
which should give you a nice output like this screenshot.