Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding a Link
#1
Solved: 11 Years, 4 Months, 4 Weeks ago
I am trying to find links on a web page. The attached pdf shows the code I have and the table that the code is using to fiind the Links. I tried using just the href of the Link object. Currently, my code is trying to use the Link properties for the name and href coulmns of the table. Can someone help me look mover why my code does not work.

My code:
Code:
For r = 2 to rNumber ' loop thru your DocView values (from 2 to rNumber or set to #)
    'DocView
    ReportType = ObjExcel.Cells(r,3)
    'Href
    Hreff = ObjExcel.Cells(r,4)
    
Browser("Wisdom").Page("Wisdom IA_2").Frame("parent_2").Link("href:="&Hreff; "name:="ReportType).Click


Attached Files
.pdf   Grab Href and DocView.pdf (Size: 123.88 KB / Downloads: 144)
Reply
#2
Solved: 11 Years, 4 Months, 4 Weeks ago
Hi,

Please try using below code:

Code:
For r = 2 to rNumber
    'DocView
    ReportType = ObjExcel.Cells(r,3)
    'Href
    Hreff = ObjExcel.Cells(r,4)
Browser("Wisdom").Page("Wisdom IA_2").Frame("parent_2").Link("href:="&Hreff,"name:="&ReportType).Click
Next

Regards,
Parminder
Reply
#3
Solved: 11 Years, 4 Months, 4 Weeks ago
Parminder,

Thx, but nope the change still gave me the same error message.

The script sees the link, but the code fails. (see attachment)

The funny thing is that I create my dataTable using the page that I am currently trying to select the Lnk objects on. Can I somehow reuse this cose to help selecrt the links?
Code:
Set TableObj = Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All")

Set LinkObj = TableObj.ChildItem(r, c, "Link", k)
LinkName = LinkObj.GetROProperty("innerText")
LinkHref = LinkObj.GetROProperty("href")

LinkName  = objExcel.Cells(rNumber, 3).Value
LinkHreff = objExcel.Cells(rNumber, 4).Value


Attached Files
.pdf   Finding Link on web page to click.pdf (Size: 173.45 KB / Downloads: 113)
Reply
#4
Solved: 11 Years, 4 Months, 4 Weeks ago
Hi Lorena,

Please see if below approach helps you:

Code:
For r = 2 to rNumber
'DocView
ReportType = ObjExcel.Cells(r,3)
'Href
Hreff = ObjExcel.Cells(r,4)
href_app=Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All").ChildItem(r,4,"Link",0).GetROProperty("href")  'Use this approach if elements in the application are in same order as in the excel file otherwise use another loop For loop for table
name_app=Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All").ChildItem(r,4,"Link",0).GetROProperty("innertext")

If href_app= Hreff and name_app=ReportType Then
    Browser("Wisdom").Page("Wisdom IA_2").Frame("parent").WebTable("Select All").ChildItem(r,2,"Link",0).Click
    Else
    Reporter.ReportEvent micFail, "Link is not present at appropriate position","Step Failed"
End If

Next

I doubt the way you are looping through excel because for looping through excel is done using "Usedrange".

An alternate way can be by importing the excel file into global sheet in qtp and then running the loop on datatable.

Regards,
Parminder
Reply
#5
Solved: 11 Years, 4 Months, 4 Weeks ago
Parminder

Thx for this most helpful responce. I will try this in the near future.

I was running out of time, so I went a different route. I dont think I can use the href propertie as I thought I should be able to (copy/paste). I find the href property in the table, copy the href property, but on saying find and use it, nope.

I ended up using the abs_x and abs_y. Since I import the object properties on each run, I can easily get the x-y cord for each link. The only property other than the href that is different for each link are the abs locations. So, if buttons move, I will still find them and use there new locations. Works great.

When I have a moment, I will try your idea. Thx for being so kind and helpful.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation UFT is not finding object in runtime but able to locate the object from repository amar.vallapreddy 1 2,741 02-25-2014, 02:22 PM
Last Post: guin.anirban
  Finding the correct Link mv8167 2 4,444 01-24-2012, 07:58 PM
Last Post: mv8167
  Finding the correct WebTable mv8167 0 2,437 12-07-2011, 02:38 AM
Last Post: mv8167
  Finding Links with Paren's mv8167 10 7,687 09-27-2011, 02:46 PM
Last Post: Ankesh
  Finding WebElements mv8167 7 9,578 06-30-2011, 11:05 PM
Last Post: parminderdhiman84

Forum Jump:


Users browsing this thread: 1 Guest(s)