Any element on a web page may be found by its XPath. Moreover, it is possible to locate the same element using a number of different XPath statements. For example:
//a /html/body/ul/li/a //a[@id='lnk5']
All three may point to the same element.
By default Rapise will construct an XPath statement meeting the following requirements:
instead of the full path
XPath uses path expressions to select nodes in an XML document. The node is selected by following a path or steps. The most useful path expressions are listed below:
Selects all child nodes of the named node
Selects from the root node
Selects nodes in the document from the current node that match the selection no matter where they are
Selects the current node
Selects the parent of the current node
In the table below we have listed some path expressions and the result of the expressions:
Selects all the child nodes of the bookstore element
Selects the root element bookstore
Note: If the path starts with a slash ( / ) it always represents an absolute path to an element!
Selects all book elements that are children of bookstore
Selects all book elements no matter where they are in the document
Selects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element
Selects all attributes that are named lang
Web pages sometimes use HTML frames. The XPath works inside the frame contents. We use following syntax to combine multiple XPath statements into a single line:
The special statement:
Is used as a separator for XPath statements pointing to constituent frames.
The top-level frame is found by name 'main'
Then the frame's contents are searched for the third <a> element (i.e. 3rd link on a page).
Web pages will often represent the results of searches and queries as formatted tables. As described in the HTML tables guide, you can use XPath to make the verification of such results much easier.
Each major browser provides a number of standard ways to check the DOM in addition to available plugins and extensions. In addition, since Rapise v3.1, Rapise provides its own powerful WebSpy tool that can inspect any of the web browsers it supports.
To open up the Web Spy, open up Rapise and under the main Spy ribbon icon, select 'Web Spy'. Then click on the Web Spy in the ribbon or on the main recording activity dialog box. This will display the Rapise web spy:
Upon learning a web element in Rapise, you get an object of type HTMLObject . Each HTMLObject provides set of functions to facilitate the cross-browser access to web element parents and children.
Returns n-th child (zero-based).
Returns number of children elements for this one.
Returns parent element (if any) with given attribute matching given string or 'regex’
Returns specified attribute.
Returns next sibling element for this one.
Returns parent element having this element.
Return previous sibling element for this one.
Returns Root element having this element.
There are a number of Firefox plugins that may help you to construct and verify your XPath statements:
XPath Checker by Brian Slesinsky
FirePath by Pierre Tholence
XPather by Viktor Zigo (no longer maintained)
Similarly for Google Chrome, there are several plugins:
XPath Helper by Adam Sadovsky
XPath by Tejji
Selected files will be attached to any email sent on saving ticket.
Select files to upload
Or drag and drop files here
Save to upload the selected file(s)