Micro Focus QTP (UFT) Forums
click each web link in a page using Index or other method in QTP - 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: click each web link in a page using Index or other method in QTP (/Thread-click-each-web-link-in-a-page-using-Index-or-other-method-in-QTP)

Pages: 1 2


RE: click each web link in a page using Index or other method in QTP - QTPgrd - 07-14-2009

Use the below script to check that content of page should not be "Page cannot be displayed

Code:
Set obj_LinkDesc = Description.Create
obj_LinkDesc("html tag").value = "A"
Set AllLinks = Browser("name:=Google").Page("title:=Google").ChildObjects(obj_LinkDesc)

msgbox AllLinks.Count

For i = 0 To AllLinks.Count

    Set obj_LinkDesc = Description.Create
    obj_LinkDesc("html tag").value = "A"
    Set AllLinks = Browser("name:=Google").Page("title:=Google").ChildObjects(obj_LinkDesc)
    AllLinks(i).Click
    Wait 2
    
    If  Browser("name:=Cannot find server").Page("title:=Cannot find server").Exist Then
         Msgbox ("Problem")
         Else
         Msgbox ("No Problem")
    End If

    Browser("opentitle:=Google").Back



RE: click each web link in a page using Index or other method in QTP - mss - 07-17-2009

Hi QTPgrd,

Above code may work if web page opening the new data in same page after we click on the link.

But here scenario is some links will open data in same page and some will lead to new pop up window. we need to test both type of the links.
how can we achieve this from above aproach.


Thanks,


RE: click each web link in a page using Index or other method in QTP - supputuri - 07-20-2009

Hi mss,

yes we can achive the both things with little modifications in the QTPgrd post.

Modification required is,
1) add one condition loop(if..else..end) with window exist (If window exist close)
2) Make sure that you have captured the url before clicking on the link every time and if window is not displayed i.e else part then compare the current url with prev captured url if both are diff then use (browser("X").back) which will bring you back to the previous page.

Let me know if you need any more information.


RE: click each web link in a page using Index or other method in QTP - kowshik - 04-29-2017

(06-16-2009, 12:57 PM)ursvinod Wrote:
Code:
Set oLinks = Description.Create
oLinks("micclass").value = "Link"
objLinks = Browser("B").Page("P").Frame("body").ChildObjects(oLinks)

LinkCount = objLinks.Count

For i = 0 to LinkCount-1

objLinks(cint(i)).Click

Next

how to click the first link inside the web element dynamically