SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

Use 'storedVars' with "storeEval" command with example in selenium IDE

Selenium "storeEval" command
"storeEval" command is generally used with scripts in selenium IDE software testing tool. It is useful to store result of the script in to specified variable and latter on we can use that variable's value whenever required.

'storedVars' - JavaScript associative array
'storedVars' is JavaScript associative array having string indexes and is useful to manipulate or access a variable value within a JavaScript snippet.



Let we learn how to use "storeEval" command with 'storedVars' array with few examples in selenium IDE software testing tool so that you can understand it better.

New Test
CommandTargetValue
store15variableA
store10variableB
storeEvalstoredVars['variableA']-storedVars['variableB']k
echo${k}

In above example, 'variablewA' and 'variablewB' stores the value 15 and 10 respectively. Now what "storeEval" command will do is, it will subtract the value of variable 'variablewB' from the value of 'variablewA' and store it in to new variable 'k'. Here you can see, I have used script using 'storedVars' like 'storedVars['variablewA']-storedVars['variablewB']' for subtraction. Here 'storedVars' will access the value of both the variables. Don't make any mistake in this string format otherwise it will not work.

Let me give you another example of "storeEval" command with 'storedVars'.

New Test
CommandTargetValue
storeSELenium IDevariableA
storeEvalstoredVars['variableA'].toUpperCase()uppercase
echo${uppercase}
storeEvalstoredVars['variableA'].toLowerCase()lovercase
echo${lovercase}
In above software test example, First "storeEval" command will convert string "SELenium IDe" into upper case using ".toUpperCase()" and store it in variable 'uppercase'. Same way second "storeEval" command will convert string "SELenium IDe" into lower case and store it in to lowercase variable.

No comments:

Post a Comment