Micro Focus QTP (UFT) Forums
object's description matches more than one - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: object's description matches more than one (/Thread-object-s-description-matches-more-than-one--6913)



object's description matches more than one - sia sharma - 10-17-2012

Hi all,

I have a web Element in my application which is getting reated in diffrent positions.

I want to capture the value of that element ....here is my code

Code:
B=Browser("name:=.*").Page("title:=.*").WebElement("html tag:=B","height:=14").GetROProperty("innertext")

but it gives a error saying

"[ WebElement ]" object's description matches more than one of the objects currently displayed in your application. Add additional properties to the object description in order to uniquely identify the object.

which is obivious bcoz the same web element is dispalyed at diffrent positions.

My question is ......

how can i select any 1 of them?



Thanks
sia


RE: object's description matches more than one - Ankesh - 10-17-2012

try using index property.


RE: object's description matches more than one - harishshenoy - 10-18-2012

try index property as mentioned by 'ankesh' below is the code.

Code:
B=Browser("name:=.*").Page("title:=.*").WebElement("html tag:=B","height:=14" , "index:=0").GetROProperty("innertext")


Thanks,
Harish


RE: object's description matches more than one - sia sharma - 10-18-2012

Code:
B=Browser("name:=.*").Page("title:=.*").WebElement("html tag:=B","height:=14" , "index:=0").exists

B=Browser("name:=.*").Page("title:=.*").WebElement("html tag:=B","height:=14" , "index:=1").exists

B=Browser("name:=.*").Page("title:=.*").WebElement("html tag:=B","height:=14" , "index:=2").exists

B=Browser("name:=.*").Page("title:=.*").WebElement("html tag:=B","height:=14" , "index:=3").exists

B=Browser("name:=.*").Page("title:=.*").WebElement("html tag:=B","height:=14" , "index:=4").exists


can i use loop instead of this if yes how?


RE: object's description matches more than one - Ankesh - 10-18-2012

below is the sample code.

Code:
for i=0 to 5
Browser("name:=.*").Page("title:=.*").WebElement("html tag:=B","height:=14" , "index:="&i)
Next

Regards,
Ankesh


RE: object's description matches more than one - sia sharma - 10-18-2012

what if the 5 no is not fixed ....its varieng every time ?
for i=0 to 5(diffrent for every run)?


RE: object's description matches more than one - Ankesh - 10-18-2012

Use child obejcts to get the total count and then loop it.

i have given a sample code to you. You need to edit it.


RE: object's description matches more than one - Ankesh - 10-18-2012

Please note to check the existance of any object you should use Exist.

Code:
If Browser(...).Page(...).Link(...).exist Then
'''
End IF
Your bwlow code will not work as you are just specifying the index,
Code:
Browser("name:=.*").Page("title:=.*").Link("index:="&x)

You should use the below code instead.
Code:
if Browser("name:=.*").Page("title:=.*").Link("html tag:=A","text:=Rate this","index:="&x).Exist Then
'do your task
End IF

Regards,
Ankesh


RE: object's description matches more than one - Ankesh - 10-19-2012

Reporter event syntax is wrong.

It should be,

Code:
Reporter.ReportEvent micPass,"Chk link existance","Link Exist".

try and see.

Regards,
Ankesh


RE: object's description matches more than one - sia sharma - 10-19-2012

GR8 .......IT worked ....

Thank you so Much Smile