assertNumericCompare

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.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 13, 2006

    Dave Hanna says:

    This extension works really well but there are some suggestions that I would lik...

    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.