|
Problem Description
How do you use the eValid DOM manipulation commands to modify
an anchor-tag's attributes to deliver the page to a
different
specified new window than the one given in the HTML passage.
Background Information
This HTML anchor tag opens the specified URL in the current window:
(1) <A HREF=../URL>Title Of Page</A> [Opens in the current window]
If the passage is modified to be written like this:
(2) <A HREF=../URL TARGET=NEW-WINDOW>Title Of Page</A> [Opens this page in new windows named "NEW-WINDOW"]
then the page is opened with a target attribute having the value NEW-WINDOW and labeled using the TITLE property.
Solution Description
The goal of this example is to make (1) behave like (2) due to actions
taken on the page from within the eValid script.
In either of the two forms above, because the tag is an <A HREF=...> the DOM for the associated element will contain the target attribute. In (1) the value of that attribute is "" [blank]; in (2) the value of that attribute is "NEW-WINDOW".
What the script does is assign a new value to the attribute in (1). It does this through this set of steps:
Script Explanation
Here is the script which performs the above steps.
# # Recording by eValid V9 # Copyright (c) 2013 by Software Research, Inc. # Recording made on: Microsoft Windows Vista Service Pack 1 (IE 7.0) # ProjectID "Project" GroupID "work" TestID "modifyA.target" LogID "AUTO" ScreenSize 1280 1024 FontSize 0 DeleteCache DeleteCookies # Navigate to a webpage then Choose and Click on an Anchor Tag... InitLink "http://www.e-valid.com/Products/Documentation.9/DOM/Examples\ "/change.target.html" Wait 1381 FollowLink 0 48 "<A HREF=../URL>Title Of Page</A>" "http://www.e-valid.com" \ "/Products/Documentation.9/DOM/Examples/change.target.html" "" Wait 2637 # Find the above selected Anchor Tag property... IndexSet 0 IndexFindElement 0 DOWN "innerHTML" "<A HREF=.../URL>Title Of Page</A>" "" # Add the associated attribute value "TARGET=NEW-WINDOW"... ValueSet "NEW-WINDOW" ValuePutElement 0 "target" "" # Clicking on the modified but same Anchor Tag now results in the page # being delivered into a new window named NEW-WINDOW... IndexFollowLink 0 "" # End of Script.
Download "modifyA.target.evs"
Notes
This method works because the browser automatically creates
a standard set of element attributes for known HTML tag types
and leaves their values blank if they are not specified.
Not every HTML tag is treated this way.
eValid's
ValuePutElement will have no effect if it is asked
to insert a value into an element attribute
if the attribute is not already defined
(eValid does not create new attributes).