XPath Using UFT
XPath is one of the Object Identification technique introduced in QTP 11 by HP. XPath Object Identification provides greater flexibility when testing Web applications and used as a performance enhancement during test execution.XPath selects nodes from an XML document for identifying an object in Web applications.XPath cannot be identified through an Object Spy.
To illustrate XPath object identification technique, the following HTML source code is used.
The output of the above HTML is shown below.
In above page, every time value of id will be change whenever it will reloaded.
Assume that now UFT will identify the object using name and id property.
If page reloaded, then value for the id and name propertyof the object will change. Using xpath based object identification, we will solve it.
XPath Using Object Repository
If you are using UFT shared/local object repository, follow the below steps:
- Options for identifying XPath can be accessed from Tools -> Options-> GUI Testing -> Web -> Advanced .
- Un-Check the ‘Learn and run using automatic XPath identifiers’
- Disable the smart identification for the object which you want to work with xpath i.e. for the above example disable smart identification for webEdit using Tools->Object Identification options
- Now add two object to object repository and delete the ordinal identifiers id if added.
- Click on ‘Add’ button in object description and add the XPath Property to the test object description.
- To identify the first input box, added the '/html/body/form/center/input[1] ' value to the xpath object property for the first webedit box. In this example, UFT identifying the object using name property too. Hence removing name property, so that it should work only on xpath property value.
- For the second edit box, added the code:/html/body/form/center/input[2]
Refer http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXPXSLT3.html for more details on how xpath works.
UFT does not recognize substring() and probably other advanced options.
ReplyDelete