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 | ||
Command | Target | Value |
store | 15 | variableA |
store | 10 | variableB |
storeEval | storedVars['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 | ||
Command | Target | Value |
store | SELenium IDe | variableA |
storeEval | storedVars['variableA'].toUpperCase() | uppercase |
echo | ${uppercase} | |
storeEval | storedVars['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