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


3 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.

Leave a Reply

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