QTP XPath examples to identify web objects. XPath is a language for addressing parts of an XML document. Xpath expressions to select nodes or node-sets in an XML document.
In this blog, we have listed some useful XPath locating techniques for QTP (Automation Testing Tool). If you are a beginner, you can refer this list to improve object locating strategy.
Identifying using ID attribute
obj.WebEdit("xpath:=//input[@id='htmlID']").Set "QTP"
Identifying using Type attribute
'Setting value in first textBox obj.WebEdit("xpath:=//input[@type='text'][1]").Set "QTP"
Identifying using Tagname
'Highlighting first listBox obj.WebList("xpath:=//select[1]").Select "London"
Identifying using Innertext
'Clicking Google link obj.Link("xpath:=//a[.='Google']").Click
Identifying WebTable based on Rowcount
'Highlighting the table which has only two rows obj.WebTable("xpath:=//table[count(.//tr)=2]").Highlight
Comments(0)