Micro Focus QTP (UFT) Forums
Unable to Click on Mutiple Links in Web Table - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Unable to Click on Mutiple Links in Web Table (/Thread-Unable-to-Click-on-Mutiple-Links-in-Web-Table)



Unable to Click on Mutiple Links in Web Table - branjitk - 06-12-2012

Hi All,

I am having error while click on Multiple Links using childobjects method.
I am calculating the link count, for click on each link i am using For loop
but it works only for first link from second link is showing General Error.
Below i am using code like this.

Code:
If  Browser("Browser").Page("-- Welcome to YANG MING").Frame("right_3").WebTable("Service").Exist(10) Then
     Set Desc = Description.Create( )
     Desc("micclass").Value = "Link"
     Set objLinks = Browser("Browser").Page("-- Welcome to YANG MING").Frame("right_8").WebTable("Service").ChildObjects(Desc)
      LinkCount = objLinks.Count
      ' msgbox(LinkCount)
     For l = 0 to LinkCount-1
     objLinks(l).Click
      Next
End If



RE: Unable to Click on Mutiple Links in Web Table - sshukla12 - 06-12-2012

Could u please provide the snap shot of application and error u r getting.

Regards,
Sankalp


RE: Unable to Click on Mutiple Links in Web Table - branjitk - 06-12-2012

Hi Sankalp,
ThankYou For your reply,
The Screen Shot is attached.

Regards,
Ranjit Kumar B


RE: Unable to Click on Mutiple Links in Web Table - sshukla12 - 06-12-2012

Hi,
When u click the link 1st time a new page is open , due to which reference object u have created is lost.
I implemented the same on google home page.
Below is the code, use it as a refrence.

Code:
SystemUtil.Run "iexplore.exe","www.google.co.in"
Set desc=Description.Create()
desc("micclass").Value="Link"
desc("html tag").value="A"
Set obj=Browser("Google").Page("Google").ChildObjects(desc)
MsgBox(obj.Count)
For i=0 to obj.Count-1
    Set odesc=Description.Create()
    odesc("micclass").Value="Link"
    odesc("html tag").value="A"
    Set obj1=Browser("Google").Page("Google").ChildObjects(odesc)
    obj1(i).Click
    'Browser("Google").Page("Google").Link("Search").Click
    Browser("Google").Close
    SystemUtil.Run "iexplore.exe","www.google.co.in"
Next


Regards,
Sankalp


RE: Unable to Click on Mutiple Links in Web Table - ssvali - 06-12-2012

Hi,

Can you please us that after clicking first link, will a new browser will open ?


Hi ,
Pls try the below code and let us know the result

Code:
SystemUtil.Run "iexplore.exe","www.google.co.in"
Set desc=Description.Create()
desc("micclass").Value="Link"

Set obj=Browser("Browser").Page("Page").WebTable("ATable").ChildObjects(desc)

For i=0 to obj.Count-1
    Set obj1=Browser("Browser").Page("Page").WebTable("ATable").ChildObjects(desc)
val =  obj1(i).GETroProperty("text")
Print val
    obj1(i).Click
    Wait(2)
    Browser("Browser").Back
Next



RE: Unable to Click on Mutiple Links in Web Table - branjitk - 06-12-2012

Hi sankalp,
Thank you very much,
The code is working perfectly.


RE: Unable to Click on Mutiple Links in Web Table - sshukla12 - 06-12-2012

Glad to hear it worked 4 U

Regards,
Sankalp