Micro Focus QTP (UFT) Forums
How to get Link name before clicking it - 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: How to get Link name before clicking it (/Thread-How-to-get-Link-name-before-clicking-it)



How to get Link name before clicking it - sqadri - 12-22-2011

Hi'

I am trying to read the name of a link before I can click it. When I hover mouse over it it gets highlighted but I cannot get its name till I click it.

So could someone please tell me how to read the name of a link without clicking it.

Thanks,
Sqadri


RE: How to get Link name before clicking it - sshukla12 - 12-22-2011

Hi,
If u have more than one link in your page u can go for Descriptive Programing.
Code:
Dim obj
Dim obj_link
Dim link_name
Set obj=Discription.Create
obj("html tag").value=XX (use spy to get the value of XX)
obj("micClass").value="Link"
Set obj_Link=Browser(aa).Page(bb).link(obj)
Foreach a in obj_Link
link_name=a.GetRoProperty("name")
Next

Regards,
Sankalp


RE: How to get Link name before clicking it - sqadri - 12-22-2011

Hi SanKalp,

Thank you for your response. I was using your approach and thought there might be better way of doing it. When I enter a search string (eg 111) then I get all the links that have 111 in them so here is how I did it now. Please let me know if there is a better way of douing it. Also could you please tell me how to read static text inside a web page?

Code:
For i =0 To linkCount -1
        linkTag = link_col(i).GetROProperty("name")
        Reporter.ReportEvent micPass, "Link Name", linkTag
        'if  group number '111' exists in the group No link then exit
        If Instr(linkTag, "111") Then
            Reporter.ReportEvent micPass, "Found Group NO", linkTag
            Exit Function
        End If
            
    Next
Thank you,
Sqadri


RE: How to get Link name before clicking it - sshukla12 - 12-23-2011

Hi Sqadri,

yes it is a good approach, u can use it and for getting the static text can you let us know from where do u want to get the text,i think you want to get the text from a web element?

Regards,
Sankalp


RE: How to get Link name before clicking it - sqadri - 12-28-2011

Sankalp,

It is a link. I have another realated issue. I have the web application version and date that is greyed out and the Version changes. How do I read this version number. I was thinking of using Text checkpoint but when the version changes it will fail. So could you please help me with this issue. The version is WebElement

Thanks,
Sqadri


RE: How to get Link name before clicking it - sshukla12 - 12-28-2011

Hi,

JUst use spy to identify the object and look for the property like innertext or text and just get that value using GetRoPRoperty.
Hope this will help u.

Regards,
Sankalp


RE: How to get Link name before clicking it - sqadri - 12-28-2011

Hi Sankalp

I used Output Checkpoint, is that a good way to read the greyed out version?

Thanks,
Sqadri


RE: How to get Link name before clicking it - sshukla12 - 12-29-2011

Hi,
If u want to check that text displayed under greyed out area is correct or not then it is good to use checkpoint but if use want to fetch that data to be used under your script then try to avoid checkpoint, use the GetRoPropert to fetch the data.

Regards,
Sankalp


RE: How to get Link name before clicking it - sqadri - 12-30-2011

Thanks,

I am using thsi code to find a link but when I want to click on this link it does not recognise it. Could you please see if there is anything wrong. aLSO WHENEVER i CLICK INSIDE A PAGE THE NUMBER KEEPS INCREASING LIKE Page(xxx_50) and next time it will be Page(xxx_51), is there a way to avoid this

Thanks,
Sqadri
Code:
Set Des_Obj = Description.Create
Des_Obj("micclass").Value = "Link"
'set parent and child objects
Set link_col = Browser("Horizon Blue Cross Blue").Page("Horizon – Plan Configurator_5").ChildObjects(Des_Obj)    
linkCount= link_col.count
For i =0 To linkCount -1
      linkTag = link_col(i).GetROProperty("name")
      Reporter.ReportEvent micPass, "Link Name", linkTag
      'if  group number '111' exists in the group No link then exit
                
       If Instr(linkTag, groupNo) Then
    Reporter.ReportEvent micPass, "Found Group NO", linkTag
             FAILS ON THE FOLLOWING LINE
             Browser("xxx").Page("xxx_50").Link(linkTag).Click