Reply
Contributor
gkarumba
Posts: 85
Registered: 09-14-2008
0
Accepted Solution

How does iTest identify/name an object which does not have any window id or name mapped

AFAIK, iTest identifies an object in a HTML page by the object's name or by the window id. eg. ":name=btnG;" If an object does not have any name/id mapped to it, then iTest record that object in a different way, something like, "://TR[4]/TD[2];" Question is, how does this naming/indentification done for an object which does not have any name/id. Do you have any document in this regard.
Community Leader
PaulD
Posts: 1,214
Registered: 09-02-2008

Re: How does iTest identify/name an object which does not have any window id or name mapped

iTest's web application works by creating what we call a "map" of each web page.  This map describes all of the objects on the page (tables, spans, buttons, images, etc.)  This map is an XML document with one tag representing each object and organized in a hierarchy matching the containment.  In fact, the document is almost identical to the HTML describing the page, except fixed to become proper XML.  If you are familiar with how browser internals work, our map is actually the DOM used internally to the browser.  In other words, we identify objects more or less the same way that it is done by javascript on the page.

 

Our targets are mostly XPATH queries that operate on the XML map to identify a node in the DOM.   We also support a few special syntaxes other than XPATH for convenience such as link=foo which is a shorthand way of writing an XPATH query that finds an object that has an href and the text "foo".  But if one of these simple shorthand ways isn't sufficient, then any valid XPATH expression is acceptable that will return a node in the document.  From that we find the corresponding object in the DOM and take action on it.

 

In this example, then //TR[4]/TD[2] is a target that is an XPATH expression.  It says, "Look everywhere in the DOM for nodes called 'TR'.  Take the fourth one of these, and then under it, take the second node called 'TD'."  

 

You can look at the DOM by using the showPage action as a step in your test case.  It will dump out the full DOM in the response.

 

It's important to understand that the DOM does not necessarily match the HTML returned by the server.  That's because client-side javascript can manipulate the DOM directly.  So after the page loads, the script on the page might continue to change the DOM.  This is very common in so-called "web 2.0" or "AJAX" applications.  Happily, iTest is using the underlying DOM itself, and so works very well with these active web applications.

Contributor
gkarumba
Posts: 85
Registered: 09-14-2008
0

Re: How does iTest identify/name an object which does not have any window id or name mapped

Thanks PaulD, for the detailed information. Is there any easy/quick way to get the XPATH query for an object from showPage or snapshot command output?
Community Leader
PaulD
Posts: 1,214
Registered: 09-02-2008
0

Re: How does iTest identify/name an object which does not have any window id or name mapped

Yes.  Open the Structure view.  While you have the snapshot step selected, the Structure view should show you the DOM for the page.  If you select a node in the tree in this view (corresponding to an object on the web page), then the textbox at the top of the Structure view will show you one possible XPATH to get to that object.  You can also use alternative XPATH queries in that textbox and when you click Evaluate, it will show you the matching nodes.  This can be a very useful tool for trying out different target variants.

 

I won't go into it here, but you may want to consider using form maps.  These let you construct a list of named targets so that you don't have to keep figuring out XPATH each time.

Expert
KumarS
Posts: 2,233
Registered: 08-30-2008
0

Re: How does iTest identify/name an object which does not have any window id or name mapped

Another way to find out the XPATH for controls is the way Preet described it in target finder feature in the web application window in another thread.
Community Leader
PreetS
Posts: 413
Registered: 09-03-2008
0

Re: How does iTest identify/name an object which does not have any window id or name mapped