XPath Examples for QTP Web Objects


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.

Identifying using ID attribute

Identifying using Type attribute

Identifying using Tagname

Identifying using Innertext

Identifying WebTable based on Rowcount


5 thoughts on “XPath Examples for QTP Web Objects

  1. Hi, I’m using xpath with UFT 14.0 but when I use Xpath for the webedit or list box its failing withsyntax error and not accepting the format. is there a setup required in UFT before we can use xpath?

    Regards
    Mmanir

    1. Hi
      Good Day

      For Example you got
      1)WebEdit (Surname)
      2)WebList (Title)

      Browser().Page().WebEdit(“Xpath:= //*[contains(text(), ‘Surname’)]/following::INPUT[1]”).Set “”
      Browser().Page().WebList(“Xpath:= //*[contains(text(), ‘Title’)]/following::SELECT[1]”).Select “”

  2. If your xpath looks something like this then (“xpath:=//*[@id=”2-value”]”)
    then remove ” after the id value and replace it with single quote ‘. Which looks something like below.(“xpath:=//*[@id=’2-value’]”) and then it should be good.

    1. How to write the xpath on this? I see below properties on Obj Resp manager
      //DIV[@id=”PRODUCT-header”]/H5[1]/BUTTON[1] and html tag BUTTON.

  3. Hello..need Xpath help in UFT..i have this one on Obj Res Repository – xpath = //DIV[@id=”product-header”]/H5[1]/BUTTON[1] and html tag is BUTTON. How should this be written? I tried the below one and it didn’t identify the obj
    xpath:=//BUTTON[@id=’product-header’]/H5[1]/[1]

Leave a Reply

Your email address will not be published. Required fields are marked *