|
Background
The eValid DOM index/motion algorithmic/structural testing capability makes it possible
to produce robust tests which behave independently of page specifics.
Use of the DOM Manipulation Resources leads to tests that are able to operate at a level of abstraction above that of the usual eValid command level. This example is one of a series that illustrate how this process works. Please see the Guide To Examples for the complete set.
Description of Tested Feature
This example demonstrates the use of finding elements based on the expressions alternative. When one is working with a webpage where there are multiple IMAGES, all/some which share common attributes, the "IndexFindElementEx" script command allows you to also include additional attributes or strings to search with.
Index/Motion Command Sequence
Here is the command sequence that achieves the result:
... IndexSet 0 IndexFindElementEx 0 DOWN "name: " "value: " "name: " "value: " "frame" IndexFollowLink 0 "frame" ...
eValid Script
Here is an example eValid script that demonstrates "IndexFindElement" vs. "IndexFindElementEx".
# Recording by eValid V9 # Recording made on: Microsoft Windows Vista Service Pack 1 " # ProjectID "Project" GroupID "Test" TestID "example15" LogID "AUTO" ScreenSize 1440 900 FontSize 1 DeleteCache DeleteCookies # How does eValid differentiate between various IMAGE selections... InitLink "http://www.southwest.com/" Wait 2245 # Recorded command with ADDED NO_NAV... #------------------------------------------------------------------------ FollowLink 0 83 "" "http://www.southwest.com/cgi-bin/buildItinerary2?ref=bkflt_hp_wl_tt" "" NO_NAV SyncOnElementProperty 0 "id" "submitBookFlights" "" Wait 2228 ElementClick 0 564 700 437 "bd34" "" "" SyncOnText 0 "Enter Confirmation Number" "" Wait 1500 #------------------------------------------------------------------------ # (NON-UNIQUE attributes, IMAGES which require additional EXPRESSION identifiers...) InitLink "http://www.southwest.com/" Wait 2245 # ADDED ALTERNATIVE Structural command sequences to search using "IndexFindElementEx"... #------------------------------------------------------------------------ IndexSet 0 IndexFindElementEx 0 DOWN "name:tagName" "value:IMG" "name:alt" "value:Book A Flight" "name:nameProp" "value:book-a-flight_init.gif" "" IndexFollowLink 0 "" NO_NAV SyncOnElementProperty 0 "id" "submitBookFlights" "" Wait 2228 IndexSet 0 IndexFindElementEx 0 DOWN "name:tagName" "value:IMG" "name:alt" "value:View or Change Your Flight" "name:nameProp" "value:change-flight_init.gif" "" IndexElementClick 0 "" SyncOnText 0 "Enter Confirmation Number" "" Wait 1500 #------------------------------------------------------------------------ # (UNIQUE attributes, IMAGES with distinct identifiers...) InitLink "http://www.southwest.com/" Wait 2245 # ADDED Structural command sequences to search using "IndexFindElement"... #------------------------------------------------------------------------ IndexSet 0 IndexFindElement 0 DOWN "id" "bd31" "" IndexFollowLink 0 "" NO_NAV SyncOnElementProperty 0 "id" "submitBookFlights" "" Wait 2228 IndexSet 0 IndexFindElement 0 DOWN "id" "bd34" "" IndexElementClick 0 "" SyncOnText 0 "Enter Confirmation Number" "" Wait 1500 #------------------------------------------------------------------------ # End of Script
How It Works
This example demonstrates the differences between using "IndexFindElementEx" and "IndexFindElement". This allows one to search attributes on a webpage using multiple identifiers. i.e. There are many tagName = IMG but each will hopefully have a unique string(s)/label(s).