Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to click on all links dynamically in UFT?
#1
Solved: 8 Years, 2 Months ago
Hi all,
i have written a script which will click on all the links in a page. the script is working fine for the first iteration while it is trying to click the second link in the page, a General Run Error is occurred. Go through the following script and correct me, suggest me.
Thanks.

Code:
set Links = Description.Create()
Links("micclass").Value = "Link"
set objLinks = Browser( "Google").Page( "Google").ChildObjects(Links)
LinkCount = objLinks.Count
msgbox LinkCount

For i = 1 To LinkCount-1
     objLinks(i).Click

Set obj1= createobject("wscript.shell")// Iam using this to navigate to
obj1.sendkeys "{TAB}"                     //previous page..
obj1.sendkeys "{BS}"
Next
Reply
#2
Solved: 8 Years, 2 Months ago
try this :
Release every object, variable after first iteration.
Reply
#3
Solved: 8 Years, 2 Months ago
Thanks buddy, it worked.
Reply
#4
Solved: 8 Years, 2 Months ago
This is exact code that works for any page in capturing all the link urls to the data table. By clicking on all the links dynamically.


Code:
Set oBrowser= Description.Create()
oBrowser("micclass").Value = "Browser"
set oPage = Description.Create()
oPage("micclass").Value = "page"

set Links = Description.Create()
Links("micclass").Value = "Link"
set objLinks = Browser( oBrowser).Page( oPage).ChildObjects(Links)
LinkCount = objLinks.Count
msgbox LinkCount


For i = 0 To LinkCount-1
set Links = Description.Create()
Links("micclass").Value = "Link"
set objLinks = Browser( oBrowser).Page( oPage).ChildObjects(Links)
  objLinks(i).Click
datatable.SetCurrentRow(i+1)
datatable("Lname",global)=Browser( oBrowser).Page( oPage).GetROProperty("href")
Browser(oBrowser).Back
set objLinks=nothing       
Next

Thanks all.
Reply
#5
Solved: 8 Years, 2 Months ago
Hi Rohan,
For your coding i am getting 'general Run error' error message.Can i know the reason? That too in the first part itself
Code:
Set oBrowser= Description.Create()
oBrowser("micclass").Value = "Browser"
set oPage = Description.Create()
oPage("micclass").Value = "page"

set Links = Description.Create()
Links("micclass").Value = "Link"
set objLinks = Browser( oBrowser).Page( oPage).ChildObjects(Links)
LinkCount = objLinks.Count
msgbox LinkCount
Reply
#6
Solved: 8 Years, 2 Months ago
restart the QTP and then try....
Reply
#7
Solved: 8 Years, 2 Months ago

Hi,

Can anybody suggest me to find the number of links within the current page only. The codes that have been suggested will get the count of links in other pages also.

Thanks in advance
Reply
#8
Solved: 8 Years, 2 Months ago
Hi Rohan'

i am getting same issues,it was such as  General Run Error is occurred.please suggested me about script.

Thanks,
Anand.
Reply
#9
Solved: 8 Years, 2 Months ago
how to Release every object, variable after first iteration????
Reply
#10
Solved: 8 Years, 2 Months ago
try the below code
Code:
Set Des_Obj = Description.Create
Des_Obj("micclass").Value = "Link"
Set link_col = Browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(Des_Obj)
a = link_col.count
For i = 0 to a-1
tag = link_col(i).GetROProperty("name")
href = link_col(i).GetROProperty("url")
Browser("micclass:=Browser").Navigate href
Next
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to dynamically find the OracleFormWindow? arpan 0 1,773 04-26-2017, 12:45 AM
Last Post: arpan
Exclamation UFT doesn't recognize object in SAP at first, but recognize it after i click debug CedricMab 3 6,693 02-06-2017, 07:09 PM
Last Post: nguyen4685
  I want to click on all the links in the webtable. These links are nothing but some co abhideshpande001 0 2,657 07-22-2015, 09:36 AM
Last Post: abhideshpande001
  How to Verify Static Object Text which is changing Dynamically with Expected Result johnny77 0 3,305 06-25-2015, 11:32 AM
Last Post: johnny77
  SAPGuiSession get the active SAPGuiWindow dynamically cko77 2 5,325 01-27-2014, 12:04 PM
Last Post: cko77

Forum Jump:


Users browsing this thread: 1 Guest(s)