Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Xpath based Identification in QTP 11.0
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
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.
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
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.
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

Just another query: what would be more advantageous, Having xpath based identification of objects or html id?
Both will be unique I guess.
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
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.
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi

shall u please tell me,how to work with webelement using Xpath
for example getroproperty of an webelement
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#8
Solved: 11 Years, 3 Months, 3 Weeks ago
Nice info bro. I use 11 but never heard of it.
Reply
#9
Solved: 11 Years, 3 Months, 3 Weeks ago Wink 
--------------------------------------------------
Very helpful ravi
thanks
Reply
#10
Solved: 11 Years, 3 Months, 3 Weeks ago
I'm Glad you found the thread useful....
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question QTP Object Identification hierarchy sivakumar 2 2,964 01-22-2014, 03:48 PM
Last Post: sivakumar
  When i use xpath in OR in QTP 11, its not working ginne 0 2,910 11-12-2013, 10:02 PM
Last Post: ginne
  Automating OracleForms Based Application - QTP QTPBeginer 0 2,532 04-28-2013, 06:46 PM
Last Post: QTPBeginer
  Choosing Add-ins in QTP When Oracle forms or other IDEs used in web based application QTPBeginer 0 2,621 03-27-2013, 11:06 PM
Last Post: QTPBeginer
  QTP does not seem to support xhtml based java objects siva.kanukollu@yaho.com 0 2,781 01-16-2013, 05:03 PM
Last Post: siva.kanukollu@yaho.com

Forum Jump:


Users browsing this thread: 7 Guest(s)