How to use array with selenium ide for parameterisation

We already learnt about data driven testing by attaching external data file with selenium IDE in my previous post. In that case we have used "storeEval" command to fetch data from external .js file. Another way of data driven testing in selenium IDE is using push command. Now let we learn how can we create
array inside selenium IDE for parameterisation. Here concept is same as both previous methods but way is little different.

Here we will use "storeEval" and "getEval" commands for creating parameterisation script. Let we look at bellow given example.


New Test
CommandTargetValue
storeEvalnew Array("car","truck", "Bus", "motorcycle", "bicycle");vehicles
getEvalmyitems=0;
whilemyitems < storedVars['vehicles'].length
storeEvalmyitemsmyvar
echojavascript{storedVars['vehicles'][storedVars['myvar']]}
getEvalmyitems++;
endWhile


(Note : You need to attache external user extension file with selenium IDE to get support of "while" command in selenium IDE. Click here to read article about how to attach user extension.js with selenium IDE)

In above example,
"storeEval" command will create one array to store all vehicle's values. "getEval" command will store value 0 in variable 'myitems'. while loop will rotate until end of the array item and echo command will print related values in log every time. Execute above script in your selenium IDE first then you can use same parameterisation method with your software application test script.

4 comments:

  1. getEval command not comming.

    ReplyDelete
  2. I got the following error "[error] Unexpected Exception: TypeError: undefined has no properties. fileName -> chrome://selenium-ide/content/webdriver-backed-selenium.js, lineNumber -> 25, columnNumber -> 4" running step javascript?
    Somebody can help?

    ReplyDelete
  3. Even I am getting the same error.

    ReplyDelete
  4. Instead of getEval use : store javascript{storedVars.myitems++;}

    ReplyDelete