Your e-Business Quality Partner eValid™ -- The Web Quality Suite
Browser-Based Client-Side Functional Testing and Validation Page Timing/Tuning Transaction Monitoring. WebSite Spidering & Analysis and Realistic Server Loading.

eValid -- Result Value Validation Using DOM Commands
eValid Home

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:

  1. Perform the actions needed to get to the page showing the first value.
  2. Use DOM commands to find and extract the first string value and save it to a file as First.txt.
  3. Then, navigate and perform the steps needed to arrive at the second page.
  4. Use DOM commands to find and extract the second string value and save it to a file as Second.txt.
  5. Compare the two strings with the eValid CompareImages "First.txt" "Second.txt" command.
    (This command works to compare any two files, including those containing images.)
  6. If they compare equal, the test PASSes; if not, the test FAILs and an appropriate ERROR will be issued.

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.

  1. Arrive At The First Page
    After script startup and initial navigations (not shown), the playback sequence arrives at the page which contains the first value (the baseline), which needs to be extracted for later comparison.

    Screenshot of First Page showing First Total.

  2. Extract The First Value
    The extraction of the first value uses this command passage:
    # 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.

  3. Arrive At The Second Page
    After further manipulations and navigations, the script arrives at the page which contains the second value (which is the one to be compared to the baseline).

    Screenshot of Second Page showing Second Total, which needs to be confirmed identical to the First Total.
    Note: In the screenshot above we blanked out individual's names.

  4. Extract The Second Value
    The extraction of the second value uses this command passage, which is similar to the above:
    # 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...

  5. Perform the Value Comparison
    The first and second values are now stored in strings locally in files named "First.txt" and "Second.txt". The command that performs the file comparison is as follows:
    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.