blues
blues

Reputation: 373

Compare stored values in Selenium IDE

I am new to test automation and to Selenium IDE. With Selenium IDE, I want to store two values(integer) and compare them. Test passes if the compared result is greater than or equal to zero. So far, I only found an option to store the values and wondering if there is any option to compare the stored values. Any suggestion would be helpful.

Thanks

Upvotes: 3

Views: 6861

Answers (2)

Sudeep Krishna
Sudeep Krishna

Reputation: 79

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 

Upvotes: 1

Klendathu
Klendathu

Reputation: 793

Okay, assuming you're always subtracting A (constant value) from B(variable value), you can use some javascript to perform the test.

store | 2 | A
store | 4 | B 
storeEval | var s = false; s = eval((storedVars['B'] - storedVars['A']) >=0); | s
verifyExpression | ${s} 

replace the two store steps above with whatever you use to get your variables A and B.

The verifyExpression line will pass(return true) if result is greater than or equal to zero, will fail(stay false) if not.

Upvotes: 2

Related Questions