Using the rollup feature of Selenium

Recently someone had put forward a doubt on the usage of rollup feature in Selenium.

Rollup, in Selenium,  is a series of commands with a unique name, and optionally arguments that control the generation of the set of commands. If any one of the rolled-up commands fails, the rollup is considered to have failed. Rollups may also contain nested rollups.

Consider, I want to do below operations in a web browser –

     (a) Login to “” URL.
     (b) Type Email
     (c) Type Password
     (d) Click on “Log in”

Logically if you see, all the above 4 different activities are serving  to a single use-case – “do_login”.

Any activity (reading mail, deleting mail, sending mail etc) will need you to first login to your mailbox. So, instead of duplicating the code for “login”  across all your testcases (e.g. reading mail testcase, sending mail testcase, delete mail testcase), you can write only once the testcase code for login and then wrap-up this testcase with a name and call this code with it’s wrapped-up name across all your testcases which needs login to the mailbox as a pre-requisite. This is where the “rollup” feature of Selenium comes into picture.

Have a look at the user-extensions.js (below). You can think of this file as a re-usable library wherein I’ve defined the actual action steps i.e. logging in, typing username, typing password and signing in. I’ve then wrapped up all these actions under “do_login” rollup rule.
I haven’t hardcoded the username and password here as I wanted to read these from the testcase.
var manager = new RollupManager();

 name: 'do_login'
 , description: 'log in to'
 , args: [
 name: 'username'
 , description: 'username'
 , {
 name: 'password'
 , description: 'password'
 ], commandMatchers: [
 , getExpandedCommands: function(args) {
 var commands = [];

 command: 'open'
 , target: ''
 command: 'type'
 , target: 'login'
 , value: args.username
 command: 'type'
 , target: 'password'
 , value: args.password
 command: 'click'
 , target: 'btnLogin'
 return commands;
Now have a look at my actual testcase “rollupExample.html” (below). If you notice, here I’m just calling the rollup rule i.e. “do_login”. Along with it I’m passing the required username and password (sanjit/sanjit). Just a single line of code in my testcase and it takes care of all the login functionality!!!
Now, all you need to do is to make the Selenium core aware of your new user-extensions javascript file and then import the testcase to your selenium IDE and run. Thats all!