Micro Focus QTP (UFT) Forums
Xpath based Identification in QTP 11.0 - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Xpath based Identification in QTP 11.0 (/Thread-Xpath-based-Identification-in-QTP-11-0)

Pages: 1 2


Xpath based Identification in QTP 11.0 - ravi.gajul - 12-30-2011

Xpath object identification is a new feature in QTP 11. Here is an example I would like to share.
Code:
Dim oPage  
Set oPage=Browser("name:=Google").Page("title:=Google")  
oPage.WebEdit("xpath:=//INPUT[@name='q']").Set "learnqtp" 'Entering value in Google textbox.  
oPage.WebButton("xpath:=//INPUT[@value='Google Search']").Click'Clicking Google Search button.

For those of you who doesn't know what an xpath is...
In simple terms its a unique address of a particular element in a webpage.


RE: Xpath based Identification in QTP 11.0 - royvarum - 01-08-2012

Hi Ravi,

could you please specify what are the advantages of using XPath identification rather than standard identification by either descriptive properties of the object in the code or using the object repository, if you use anyway, a property and a value for the identification in XPath (ex. value=Google Search)

Thanks Smile
Roy.


RE: Xpath based Identification in QTP 11.0 - ravi.gajul - 01-08-2012

Xpath for a particular object is unique.We may think of it as an address location for a particular object which is unique.Hence object identification is easy.We need not look of multiple properties for unique identification of an object.In scenarios where properties doesn't make unique description , xpath makes the job easy and enhances performance(time spent in comparing multiple properties is saved).However performance depends on relative/absolute xpath given.Both paths point to the same object.
Hope this clarifies your query Smile


RE: Xpath based Identification in QTP 11.0 - Tarik Sheth - 01-09-2012

Hi,

Just another query: what would be more advantageous, Having xpath based identification of objects or html id?
Both will be unique I guess.


RE: Xpath based Identification in QTP 11.0 - royvarum - 01-09-2012

I think if i understand Ravi correctly, I can summarize the difference between the standard property identification of QTP and XPath method:

Standard properties identifications (descriptive/OR) says to QTP:
"Go search for ALL objects in a specific hierarchy that match a set of property values, hopefully the properties match a single object"

XPath identification says to QTP:
"Hey! I'm here! (or not here), You have a direct reference to me!, no need to search for anything"

its kind of abstracted but hope this helps.

Roy.


RE: Xpath based Identification in QTP 11.0 - rjkmr.aiht - 05-17-2012

Hi

shall u please tell me,how to work with webelement using Xpath
for example getroproperty of an webelement


RE: Xpath based Identification in QTP 11.0 - ravi.gajul - 07-10-2012

Hi,

Consider the below HTML object
<INPUT class="hover" id=1452 size=45 value="Enter id" name=n>
Now we can identify this object using various XPATH combinations.Few examples shared below
  • //INPUT[@class='hover']
  • //INPUT[@id='1452']
  • //INPUT[@id='1452',@class='hover']

By using such XPATHS, we can also limit our object search.For instance;if we want access to an object inside a WebTable Cell, we know that the object will have a parent with a TD html tag.In which case we can use XPATH like
//TD//INPUT[@name='n'

Regards,
Ravi


RE: Xpath based Identification in QTP 11.0 - vIns - 07-11-2012

Nice info bro. I use 11 but never heard of it.


RE: Xpath based Identification in QTP 11.0 - Nag317 - 07-11-2012

--------------------------------------------------
Very helpful ravi
thanks


RE: Xpath based Identification in QTP 11.0 - ravi.gajul - 07-12-2012

I'm Glad you found the thread useful....