Defining variables in a Selenium IDE rollup

1k views Asked by At

I have a set of selenium commands that I want to combine into a rollup, however they contain the definition of a variable. I am trying to define and then access that variable from within the rollup but it does not seem possible?

If I use Var3 as a variable I get a 'Var3 is not defined!' error. To get around this I use storedVars.Var3, but to rely on this I need to run the selenium rollup twice.

Rollup is as follows:

manager.addRollupRule({
 name: 'TestVars'
 , description: 'Testing variables'
 , pre: 'Testing variables'
 , post: 'Variables tested'
 , args: [
        {
            name: 'Var1'
            , description: 'The tab where the id should exist'
            , exampleValues: ['Whateva']
        },
        {
            name: 'Var2'
            , description: 'The icon where the id should exist'
            , exampleValues: ['YourChoice']
        }
        ] 
, commandMatchers: [
 ]
 , getExpandedCommands: function(args) {
 var commands = [];
 var Var1 = args.Var1;
 var Var2 = args.Var2;

 commands.push({
 command: 'store'
 , target: 'testVar3'
 , value: 'Var3'
 });

  commands.push({
 command: 'storeTitle'
 , target: 'Var4'
 });

   commands.push({
 command: 'storeEval'
 , target: 'alert("Var1: '+Var1+' Var2:'+Var2+' Var3:'+storedVars.Var3+' and Var4: '+storedVars.Var4+'")'
 });
  return commands;
      }
});

Called from Selenium IDE:

<tr>
<td>rollup</td>
<td>TestVars</td>
<td>Var1=456, Var2=789</td>
</tr>

Run the first time I get an alert:

Var1: 456 Var2:789 Var3:undefined and Var4: undefined

The second time I get an alert:

Var1: 456 Var2:789 Var3:testVar3 and Var4: Defining variables in a Selenium IDE rollup - Stack Overflow

To solve this I need to create multiple roll-ups each time the rollup defines a variable so separate that into another rollup and then run that - not really in the spirit of a 'rollup' but doable.

Suggestions/comments welcome ;-)

0

There are 0 answers