Now a days we see lot of angular JS applications being built.
It is said that at least 10% of the latest developing are based on angular js.
In this section we see how to configure and run a simple protractor test on angular and non angular app
Its very straight forward, mostly thats the reason why its largely adapted.
Step 1 :
Install Node.js, current version of node js when writing this blog is v10.16.2
you can download node js from Node Js download
select the windows MSI and install it. While installing it select add node js to path.
This option enable us to directly access node commands from cmd without navigating to node directory.
Node JS is like collection of several java script libraries. They are called as node modules
The installation also installs the node package manager which is required to install different node modules.
Once you have installed it go to command prompt (search-> run – >cmd)
then enter following command
It should show the current installed version, if its not there is some issue with the installation.
Now we have node js setup and ready
Open cmd and try to install the protractor, install protractor globally (all users on the machine, if not remove -g)
npm install protractor -g
More information on this site https://www.protractortest.org/#/
Usually protractor sets up the web driver manager. But if it’s not then you need to install the webdriver manager as well
Now we have to start our webdriver-manager to kick of the example test
Webdriver manager will look for webdriver connections that are being initiated by protractor.
There is one sample test that comes with protractor we can use it and create couple of more tests.
But, if we want to run on google we might want to make some changes.
At the end of start of webdriver you should see command prompt like below.
Once you started the webdriver manager, open another command prompt and run a angular example test
In the node js installation will happen typically in appdata/roaming folder go to following path, you should see following
Example path :
You should see the following, googleTest is something I have added, you don’t see it by default.
To run a test we need to use following command
What does this mean ?
Protractor reads the conf file and executes the specification file mentioned in the conf.js
Protractor uses something called Jasmin framework by default. Its called as “Describe It” framework.
Test start with Describe() – > then It() , which means action and its expected outcome.
All the code is written in java script, we can use type script too.
Once we start the example test it will perform operations on node js site and gives us the following result.
The result displayed below is formatted, I will mention how to configure different types of reports in next section.
In the next part will discuss about following
- Custom report as shown above.
- conf.js sections and how to edit.
- googleTest.js -> non angular application example.