Dashboard > Selenium > ... > Contributed User-Extensions > assertNumericCompare
Selenium Log In View a printable version of the current page.
assertNumericCompare
Added by Jonathan McBrien, last edited by Jonathan McBrien on Aug 10, 2006  (view change)
Labels: 
(None)

description

Basic numeric comparisons, between two numbers or a number (in test column a) and a range (in test column b).

Numbers may be integer or floating point. String comparisons are not supported.

example of use

Command Param 1 Param 2 Test purpose.
assertNumericCompare 5 >10 Tests whether 5 is greater than 10.
assertNumericCompare 6 <4234.2312 Test whether 6 is less than 4234.2312.
assertNumericCompare 10 ==15 Test whether 10 is equal to 15.
assertNumericCompare 10 !=15 Test whether 10 is not equal to 15.
assertNumericCompare 6 1..23 Test whether 6 is in the range 1 to 23.
assertNumericCompare 1 !0.0001..0.6545 Test whether 1 is not in the range 0.0001 to 0.6545.

Of course, you can use Selenium's store commands to create variables for use in an assertNumericCompare test.
E.g. for the test on whether 6 is in the range 1 to 23...

Command Param 1 Param 2
store 6 myVar
store 1 rangeMin
store 23 rangeMax
assertNumericCompare ${myVar} javascript{storedVars['rangeMin'] + ".." + storedVars['rangeMax']}

notes

A comprehensive usage demonstration can be found in the associated test suite.

download

Click the Attachments tab (above) to download a zip archive containing the extension and some associated tests.

This extension works really well but there are some suggestions that I would like to make:
1) Define an error message at the beginning of the code so that you get better feedback when an assertion fails:
//var msg="assertNumericComparator failed because " + targ + " doesn't satisfy " + val;
// Assert.matches(msg,"true", (targ < valNumeric).toString());

2) Somehow allow the evaluation of DOM expressions (e.g. //tr[4]/td[2]/div) instead of storing a variable first.

Site running on a free Atlassian Confluence Community License granted to OpenQA. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.6 Build:#812 Aug 06, 2007) - Bug/feature request - Contact Administrators