Creating rollups in Selenium IDE with execution logic based on storedVars can be tricky.   Storing the value of an element or its presence within the rollup command list and using if or other logic blocks via the various “flow” add ins will not work as you expect.   Nor will storing the values and then using JavaScript logic within your rollup.     Getting storedVars working in a rollup is a special kind of black magic.

Here are my methods that are working for me with my home-grown “Go With The Flow” add-in I brewed based on similar control flow plugins.

Set Vars In A Separate Rollup

I find that setting my variables in a separate rollup is a simple solution.   This ensures your variable stack exists and is set using standard Selenium IDE commands.   My example for testing if I am already logged in before prompting for user and password data and running the login:

Use JavaScript Logic

Once your variables are set they are standard JavaScript variables that will be available throughout your rollups.  You can use this fact to build standard JavaScript logic in your rollup and decide what commands the rollup will push on the stack during each execution.   In your Selenium IDE command list you can then change storedVars using various store commands and then call the rollup afterwards; in essence changing what commands are executed “on the fly”.

You’ll notice that I also do a quick check at the top to ensure the set_my_vars rollup was already run by checking that the storedVars key I need is set.   If not it echos a message to the Selenium IDE log console and skips doing anything else.


Hopefully these tricks will help you with your Selenium IDE rollup builds.    Some things to keep in mind is that things like Selenium labels or endif markers do not exist within the rollup itself if you are creating them in the rollup.    Same concept with storedVars, the storedVars[<key>] will not exists and be available to your rollup JavaScript logic if you create the var inside the rollup itself.      When a rollup that creates a storedVars entry is complete it is then available for any future commands, including rollups.

One Comment on “Selenium IDE Rollups With StoredVars Logic

  1. Hi Lance, for the testing of our SAAS product I have managed to circumvent the “the storedVars[] will not exists and be available to your rollup JavaScript logic if you create the var inside the rollup itself” issue by using another rollup (within the rollup) to use the vars created in the first rollup. That is to say, my rollup calls a rollup, which uses the storedVars created in the first rollup. Confused? In fact with a bit of tweaking one rollup can call itself – effectively meaning this issue disappears 😉

Share Your Insight

%d bloggers like this: