1

On my application i have to search for an alphanumeric id which return one or more rows of data. On each of these rows a link is present i have to click on the first link.

Unfortunately it doesn't have any unique properties so i cannot add it to the OR. Instead i used descriptive programming something like below

'returns false
page.Link("class:=ng-binding","innertext:=AplhaID","html tag:=A").Exist

QTP fails to identify the object with the above code. So Instead of this i tried using Description object something like the below code

Set oDesc = Description.Object
oDesc("class").Value = "ng-binding"
oDesc("html tag").Value = "A"
oDesc("innertext").Value = "AplhaID"

Set lnk = page.ChildObjects(oDesc)

'gives me 2 which is correct. There are two links
msgbox lnk.Count

'highlights the correct link
lnk(0).Highlight

I do not know what could be causing this behavior. I thought is could be because multiple links match the description but I perform this search for multiple ids and eventhough multiple rows are returned the descriptive programming code is able to identify the correct row and proceed.

I looked at QTP descriptive programming issue but my link's property values do not have special characters.

Community
  • 1
  • 1
Abhishek Asthana
  • 1,857
  • 1
  • 31
  • 51

1 Answers1

1

In order to use Descriptive string method, ensure that you have only one object matching the given properties.

Below statement might fail if there are more than 1 object with the given properties.

page.Link("class:=ng-binding","innertext:=AplhaID","html tag:=A").Exist

So , you need to make the statement to find an object uniquely. Try this. It will work!

page.Link("class:=ng-binding","innertext:=AplhaID","html tag:=A", "index:=0").Exist
vins
  • 15,030
  • 3
  • 36
  • 47