Wednesday, May 25, 2016

Protractor : How to implement suites in protractor

We write many scripts in order to automate functional or regression test cases using protractor but all are scattered and not in order. Sometimes we need to run a group of test cases dedicated to test a specific functionality. In that case we need to group protractor script named suite. Using suite we can make a set of scripts.

In this post we will use our sample projects that was built in our previous post.

Step 1 : Open the project and add two new folders named “addition” and “multiplication” by right clicking on project name and go to New->Directory.



Step 2 : Add a JavaScript file names “testadd1.js” at “addition” folder by right clicking on folder and go New->JavaScript File.



Now add another file named “testadd2.js”.


Step 3 : Now open testadd1.js and add the following script.


Open testadd2.js and add the following script.


Step 4 : In the same way, add two JS files “testmul1.js” and testmul2.js” on multiplication folder.


Step 5 : Open “testmul1.js” file and add the following scripts.


And Open “testmul2.js” file and add the following scripts,


Step 6 : Now open conf.js file and add suites options like the following,


Here, addition and multiplication are suites name and we use these name during running scripts.

'addition/*.js' means run all .js files located in addition folder.

'multiplication/*.js' means run all .js files located in multiplication folder.

In this way we can run either any of the suites.

Step 7 : Now open terminal window and run selenium server.


Step 8 : Now open another terminal window and run all the script located in addition folder by using addition suite. The command will be

protractor conf.js --suite addition


Common format of this command,

protractor conf.js –suite {suite name}

Pressing enter key will run the script located in addition folder. Please do not merge folder name and suite name. These two are different.

You can run any suite by using the suite name.

Now run the multiplication suite.


We can create more suites by using different files from different folders like the following,

cal: ['addition/*.js','multiplication/*.js']


Here we use different script location separated by comma.

Now run the suite,


That’s all for now.

We will see more in future.

Happy end to end testing using Protractor!!!

No comments:

Post a Comment