Compare stored values in Selenium IDE
I am new to automation testing and Selenium IDE. With Selenium IDE I want to store two values (integer) and compare them. The test passes if the compared result is greater than or equal to zero. So far I have found an option to store values and wondered if there is a way to compare the stored values. Any suggestion would be helpful.
thank
+3
source to share
2 answers
Ok, if you always subtract A (constant value) from B (variable value) you can use some javascript to execute the test.
store | 2 | A
store | 4 | B
storeEval | var s = false; s = eval((storedVars['B'] - storedVars['A']) >=0); | s
verifyExpression | ${s}
replace the above two storage steps with what you are using to get the variables A and B.
The verifyExpression line will pass (return true) if the result is greater than or equal to zero, will not (remain false) if not.
+2
source to share
store |2| A
store |4| B
storeEval |var s = false; s = eval((storedVars['B'] - storedVars['A']) >=0);| s
echo |${s}|
Executing: |store | 2 | A |
Executing: |store | 4 | B |
Executing: |storeEval | var s = false; s = eval((storedVars['B'] - storedVars['A']) >=0); | s |
script is: var s = false; s = eval((storedVars['B'] - storedVars['A']) >=0);
Executing: |echo | ${s} | |
echo: true
Test case passed
+1
source to share