12-08-2009, 04:57 PM
Hi all, how do we get to know the co ordinates of a Search text from QTP, which occurs more than once.
or how do we know the No.of occurances of a text on a page???
i was trying with below code.
when i run this script this will identify the first occurance of "Spin", but how to get the Nth occurance of Random Button.
In my case "Spin" is found two times as
1.Last Spin as Plain text and
2.Spin - A button
i need to click on Spin Button , where as it is clicking on Last Spin Plain Text.
or how do we know the No.of occurances of a text on a page???
i was trying with below code.
Code:
Call GetTextLocation
Sub GetTextLocation()
l = -1
t = -1
r = -1
b= -1
InputLink="http://www.sportingbet.com"
Set GameRef=Window("regexpwndtitle:=Microsoft Internet Explorer","text:="&InputLink&".*").WinObject("Object class:=MacromediaFlashPlayerActiveX")
If GameRef.Exist Then
result =GameRef.GetTextLocation("Spin", l, t, r, b)
If result Then
MsgBox "Text found. Coordinates:" & l & "," & t & "," & r & "," & b
x = (l+r) / 2
y = (t+b) / 2
GameRef.Click x,y,0
End If
End If
End Sub
when i run this script this will identify the first occurance of "Spin", but how to get the Nth occurance of Random Button.
In my case "Spin" is found two times as
1.Last Spin as Plain text and
2.Spin - A button
i need to click on Spin Button , where as it is clicking on Last Spin Plain Text.