|
Summary
This page describes how to use eValid's DOM manipulation commands
to validate an on-the-page calculation.
Problem Description
In this web application you have
one part of the test session that creates a value
and a second part on another screen that re-calculates the value
using a different method.
(Think here in terms of double-entry bookkeeping:
the numbers have to match when computed two independent ways.)
What is somewhat more complex about this usage is that it is different than the normal case, when you know the value in advance and can do a simple validation of the known value against the current [computed] value. Here you have two values -- both computed in real time -- that need to be confirmed as identical.
Solution Description
The eValid solution involves these functional steps:
Application Architecture
This application -- see screenshots below -- is a real-time, hosted retail
service order processing system that is supplied by a leading
restaurant services support firm.
The hosted application is built with the Oracle 9i browser-based interface
(it is being upgraded to Oracle 11i),
feed by WebLogic from data kept in a Oracle backend database system.
Sensitive details about customer names and other matter have been erased or
obscured in the screenshots shown below out of privacy concerns.
Detailed Solution Explanation
These testing steps are illustrated in the script sub-sequences and images below.
The application is an AJAX-based interface based on Oracle 8i/9i interfacing to
WebLogic and Oracle databases in the back end.
As you can see in the images, the application deals with accounting in a restaurant/bar context.
# Passage to find the first value... IndexSetEnd 0 "number:1" IndexFindElement 0 UP "innerText" "100%" "number:1" IndexMove -2 # Now, save the value to a local file... ValueSet 0 ValueGetElement 0 "innerText" "number:1" ValueSave "First.txt"
After finding the point on the page where the 100% occurs, you move backwards two indexes (the IndexMove -2 command) to position the sourceIndex to the location of the Total Gross Sales, and then pick it off and save it locally for later comparison.
We used the PageMap to identify the actual index numbers on a typical page and found that the value we want ("$32,783.88") is always located two elements before the "100%", even when the page changes due to more or fewer entries.
Note: In the screenshot above we blanked out individual's names.
# Passage to find the second value... IndexSet 0 "number:1" IndexFindElement 0 DOWN "innerText" "Total: " "number:1" IndexMove +2 # Now, save the value to a local file... ValueSet 0 ValueGetElement 0 "innerText" "number:1" ValueSave "Second.txt"
Here after finding the sourceIndex where Total: occurs, you move two indexes to the right (the IndexMove +2 command) so you have the sourceIndex positioned over the Total sales, then pick off that value and save it locally for later comparison.
We used the PageMap to confirm that the needed value is always two index positions to the right (down) from the "Total:" string. This relationship will be constant even though the table has a variable number of rows...
CompareImages "First.txt" "Second.txt"
If the two files differ then this command results in an ERROR flag in the eValid playback EventLog. That kind of action can be handled with OnErrorGoScript-type flag processing command, so that the script FAILure can provide the appropriate user alert.
In later versions of eValid (V9 #284+) the CompareStrings command could be used as well, with the advantage that with that command only the interior part of each extracted string would be compared for equality.