Your e-Business Quality Partner eValid™ -- The Web Quality Suite
Browser-Based, Client-Side, Functional Testing & Validation, Load & Performance Tuning, Page Timing, Website Analysis, and Rich Internet Application Monitoring.
© Copyright 2000-2012 by Software Research, Inc.

eValid -- Checking AJAX Autocomplete Functionality
eValid Home

Introduction
This scripting example investigates how eValid can be used to validate an AJAX autocomplete function. The two variants of the script shown below operate as follows:

  1. Introduce a partial string into the text area, for example evali.
  2. Capture the contents of the DOM after the AJAX activity has provided some suggested completions.
  3. Confirm that a required string, for example evalid, is present within the available suggestions presented by the autocomplete feature.

The goal of the script is to confirm that, among all of the possible suggested completions, that the target evalid string is among the options presented. If successful, this process effectively validates operation of the AJAX autocomplete function by confirming its results with known (expected) data.

Sample Screen
Here is a sample of the Google search input page that shows the display after typing in evali -- an incomplete substring of the required target string evalid.

eValid
Screenshot showing example autocomplete suggestions

Example Script Variant #1
The script shown below, which was first recorded "from life", has been modified manually so that it illustrates the use of the DOM processing commands to execute the test plan and verification procedure described above.

After identifying the correct sourceIndex at which to do the partial text insertion, the script waits 1 second (for the DOM to fully stabilize) and then confirms that the required reference to evalid is present in the autocomplete suggestions that are currently shown on the page, using a MatchString command.

As a secondary confirmation and more exact confirmation, the script issues an IndexFindElementEx command to search for the specific SPAN and <TD> sequence that contains the text that is represented on the screen. Hence, the command's arguments specify two matches: (i) the value evalid appears in some element's innertext: property; and, (ii) value:SPAN appears as the value of a name:tagName reference.

# Recording by eValid V9 Build #307, Build Date: (Aug 22 2011) 
# Copyright 2000-2012 by Software Research, Inc. 
# Recording made on: Microsoft Windows Vista (IE 7.0)"

ProjectID "LoadTests"
GroupID "CloudBenchMark"
TestID "ggt3EVdown"
LogID "AUTO"

ScreenSize 1280 1024
FontSize 0
DeleteCache
DeleteCookies
InitLink "http://www.google.com/"
Wait 1000
IndexSet 0
IndexFindElement 0 DOWN "name" "q" ""
Wait 1000
#InputValue 0 178 "TEXT" "" "q" "evali" "" ""
IndexInputValue 0 "TEXT" "evali" "" ""
Wait 1000
MatchString 0 "evalid" ""
IndexSet 0
IndexFindElementEx 0 DOWN "name:innerText" "value:evalid" \
	"name:tagName" "value:SPAN" ""
Wait 1000
IndexElementClick 0 ""

Wait 1025
ValidateSelectedText 0 193 0 "eValid is an automated browser that " \
	"supports web application testing, analysis, \r\nand QA." ""

Wait 3000
# End of script.

Download "ggt3EVdown.evs"

Example Script Variant #2
In this script variant, the initial operation is the same but instead of using a complex IndexFindElementEx command the script confirms that evalid appears in the page with a simpler sequence.

The script searches the page from the bottom upwards with an IndexFindElement command to confirm that evalid appears as the innerText of some element on the page. The search is done from the bottom of the page upwards because we know (from study of the page properties with the eValid PageMap command) that the required match is located in a SPAN inside a complex table structure.

# Recording by eValid V9 Build #307, Build Date: (Aug 22 2011) 
# Copyright 2000-2012 by Software Research, Inc. 
# Recording made on: Microsoft Windows Vista (IE 7.0)"

ProjectID "LoadTests"
GroupID "CloudBenchMark"
TestID "ggt3EV"
LogID "AUTO"

ScreenSize 1280 1024
FontSize 0
DeleteCache
DeleteCookies
InitLink "http://www.google.com/"
Wait 1000
IndexSet 0
IndexFindElement 0 DOWN "name" "q" ""
Wait 1000
#InputValue 0 178 "TEXT" "" "q" "evali" "" ""
IndexInputValue 0 "TEXT" "evali" "" ""
Wait 1000
MatchString 0 "evalid" ""
IndexSetEnd 0 ""
IndexFindElement 0 UP "innerText" "evalid" ""
Wait 1000
IndexElementClick 0 ""

Wait 1025
ValidateSelectedText 0 193 0 "eValid is an automated browser that " \
	"supports web application testing, analysis, \r\nand QA." ""

Wait 3000
# End of script.

Download "ggt3EV.evs"