Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
click each web link in a page using Index or other method in QTP
#11
Solved: 10 Years, 9 Months ago
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
Reply
#12
Solved: 10 Years, 9 Months ago
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,
Reply
#13
Solved: 10 Years, 9 Months ago
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.
Thanks,
SUpputuri
Reply
#14
Solved: 10 Years, 9 Months ago
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Webtable contains cell contains two links, how to click on link srinivassure 9 52,688 07-30-2016, 03:41 PM
Last Post: Akshay
  VB Script to count number of links in a web page. Suma Parimal 4 24,747 07-01-2015, 12:59 PM
Last Post: govind
  Upgraded QTP 11.0 to UFT 11.53, Object Index Properties are varying Raghava M 0 2,071 01-28-2015, 06:02 PM
Last Post: Raghava M
  General run error. Line (18): "Loop while Browser("Index:=0").Object.Busy" AshokReddy 3 4,786 12-20-2013, 01:44 PM
Last Post: sshukla12
  Unable to select a combo item by value or index martinshort 2 3,166 08-26-2013, 07:55 PM
Last Post: sudhirzpatil

Forum Jump:


Users browsing this thread: 1 Guest(s)