Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Regarding GetTextLocation
#1
Not Solved
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.

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.
Reply
#2
Not Solved
Hi ,

Try with "TextUtil" Utility object.
There is method called "GetTextLocation" associated with this Object.

Syntax:
TextUtil.GetTextLocation(TextToFind, hWnd, Left, Top, Right, Bottom[, MatchWholeWordOnly])
Return Value: Boolean

Example:
The below code searches for the word "Mercury" within the entire screen.
Code:
l = -1
t = -1
r = -1
b = -1
Succeeded=TextUtil.GetTextLocation("16",0,l,t,r,b)
msgbox Succeeded

Once its found , you could go for DeviceReplay,WSH so on so forth for clicking on that.
Reply
#3
Not Solved
Hi Sreekanth,
Thanks for letting us about the below information,

I have a small problem regarding this,

U have mentioned "Text to find" is "16" and the type of this property is string

But u were telling that
The following example searches for the word Mercury within the entire screen and clicks it if the word is found

Could you please refresh me with the above one,

Thanks,
Venkat.Batchu
Reply
#4
Not Solved
Hi Srikanth , Thanks for the Reply.

Can you please elobarate how to use that for my scenario. I Have Last Spin and Spin in my page. How to use that Textutil object for my scenario. and one more thing , in the above eexample , what that 16 mean ?
Reply
#5
Not Solved
Hi Venkat/Koti,

Yep, it should be "mercury" instead of "16" in the example.
Fyi, As part of finding the text loc., I came to know about the "TextUtil" utility Object in QTP Help.

@venkat: Henceforth I suggested to check with the above object.
You refer the QTP help for "TextUtil" object for more info. & try to implement for your scenario.

Hope I am clear on this Smile
Reply
#6
Not Solved
Hey Sreekanth,
Its strange that even in Help also it is documented wrongly,
I posted about by seeing help thats the reason i have pasted the entire context as mentioned in the help like "The following example searches for the word Mercury within the entire screen and clicks it if the word is found" .
Any way thanks alot
Thanks,
Venkat.Batchu
Reply
#7
Not Solved
The given code works fine for Mozilla 2.0 but not working for Mozilla Firefox v11.0.

I am unable to find text using the TextUtil function GetTextLocation().
Is there any equivalent function for testing on Mozilla 11.

Please reply ASAP with appropriate function or if any Addin is required.
You can also let me know if any other way is there to work with Tool bars on Mozilla v11.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  GetTextLocation method elsekra 1 8,540 03-12-2009, 06:45 PM
Last Post: MVChowdary

Forum Jump:


Users browsing this thread: 1 Guest(s)