Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Thursday 18 June 2015

XPath Using Object Repository in UFT

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:
  1.  Options for identifying XPath can be accessed from Tools -> Options-> GUI Testing -> Web -> Advanced .
  2.  Un-Check the ‘Learn and run using automatic XPath identifiers’
  3. 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
  4.  Now add two object to object repository and delete the ordinal identifiers id if added.
  5.  Click on ‘Add’ button in object description and add the XPath Property to the test object description.
  6.  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.
  7. For the second edit box, added the code:/html/body/form/center/input[2]                                                                                                                                                                  


Here is the hirechary for the above two text box.



Refer http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXPXSLT3.html for more details on how xpath works. 

1 comment:

  1. UFT does not recognize substring() and probably other advanced options.

    ReplyDelete

Note: only a member of this blog may post a comment.