Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding Links with Paren's
#1
Solved: 10 Years, 9 Months ago
From an Excel file, I have imported 15 Report Names, all work in my code except the following two.

Code:
WFI STATEMENTS BY WFA ACCOUNT (020/205)
WFI STATEMENTS BY WFA ACCOUNT (206)

In my code I use the following to click on the link.

Code:
ReportName = objDriverSheet.Cells(r,4).
Browser("W").Page("WIA").Frame("parent").Link("name:="& ReportName, "abs_x:="&absX, "abs_y:="&absY).Click

My variable list durring debug shows the full link name but the link (which is visiasble and exactly the same as the other 11) are not found to Click.

Could I be not finding the link due to the ( )?

If so, how can I better code to find these two links?

Thx everyone for looking.
Reply
#2
Solved: 10 Years, 9 Months ago
Hi Lorena,

Sometimes, the Descriptive programming doesn't work as we want although the code looks absolutly fine. Ur code is

I am not sure why is it so.

Can u plz chk if the below code works for u...

Code:
if Browser("W").Page("WIA").Frame("parent").Link("name:="& ReportName).Exist Then
    Browser("W").Page("WIA").Frame("parent").Link("name:="& ReportName).Click
End IF




try the below descriptive programming

'Description for Browser and page

Code:
Set objBrowser=Description.create
objBrowser("title").value=".*"

'Description for frame
Set ObjFrame=Description.create
ObjFrame("name").value="parent"

'Description for the Link
Set ObjLink=Description.create
ObjLink("html tag").value="A"
ObjLink("text").value=ReportName  ' the value fethced frm the excel

and Use the Below code

Code:
Browser(ObjBrowser).Page(ObjBrowser).Frame(ObjFrame).Link(ObjLink).Click

I hope this would work.
Reply
#3
Solved: 10 Years, 9 Months ago
Ankesh,

Thx for using your time to respond.

FYI, I added the X and Y locations to the link because I have more then one link with the same names. Using just ").Link("name:="& ReportName).Click failed due to different GroupNames with the same ReportNames. yikes ;-)

I used your suggested code and received a Run Error of

"Cannot identify the object "[ Link ]" (of class Link). Verify that this object's properties match an object currently displayed in your application.

Line (213): "Browser(ObjBrowser).Page(ObjBrowser).Frame(ObjFrame).Link(ObjLink).Click". "

All three variables durring debug indicate <Object>

As Prior, the ReportName does correctly indicate "WFI STATEMENTS BY WFA ACCOUNT (020/205)"

Am I needing to add any code to better locate the correct <Object>s?

Thx for your kind help.
Reply
#4
Solved: 10 Years, 9 Months ago
Hi...if you have more than 1 link in the same name, use index . plz do not use coordinates.
Reply
#5
Solved: 10 Years, 9 Months ago
Like I said, I wish I could. When I grab the link and coordinates I tried to grab the Index value also. But the Indexjust would not be located by QTP. I tried for weeks to go this route wasting tons of time. So, I use the X-Y until I can find a solution. However, even using the above, the link is loaded correctly but still on Click, the link just is not found. All of the objects "Browser(ObjBrowser).Page(ObjBrowser).Frame(ObjFrame).Link(ObjLink).Click". " All three variables durring debug indicate <Object>

Reply
#6
Solved: 10 Years, 9 Months ago
@ Lorena, i am looking into it... I will update u asap.

However, for debugging purpose of the object use <ObjectName>.text in the debug window. U can see the content of the object.
Reply
#7
Solved: 10 Years, 9 Months ago
Ankesh,

You are verfy kind to stick with me on this. Sorry, I am trying to learn.

All three object variables for
Code:
"Browser(ObjBrowser).Page(ObjBrowser).Frame(ObjFrame).Link(ObjLink).Click"
indicate <object> in the Variables list.

The ReportName equals WFI STATEMENTS BY WFA ACCOUNT (020/205) or WFI STATEMENTS BY WFA ACCOUNT (206) or the other 5 link names (which all currently run fine by using
Code:
"Browser("W").Page("WIA").Frame("parent").Link("name:="& ReportName, "abs_x:="&absX, "abs_y:="&absY).Click"

Im not sure, but perhaps the Parens are causing the issue?

I have not tried
Code:
"Browser(ObjBrowser).Page(ObjBrowser).Frame(ObjFrame).Link(ObjLink).Click"
on my currently working links, so I will.

again, thx for your help.
Reply
#8
Solved: 10 Years, 9 Months ago
Hi Lorena,

I found one solution for ur problem. I guess this might be useful.

Regular expressions are automatically used when doing descriptive programming. So you need to escape the parens with a \ in front of them.

In your case WFI STATEMENTS BY WFA ACCOUNT (020/205)

so for the above link use the DP as below

Code:
Browser("<BrowserName">).Page("<PageName>").Frame("<FrameName">).Link("name:=WFI STATEMENTS BY WFA ACCOUNT \(020\/205\)

I hope this works.. In the meantime i am looking for some alternate solution. Will keep u posted.

Regards,
Ankesh
Reply
#9
Solved: 10 Years, 9 Months ago
Ankesh,

Thx for your continued review and thoughts towards my problem.

I had somewhat thought of this but mostly dropped the idea after thinging about it.

Reason:
When I import all of the links, the link names change daily. So, I import the links into an Excel ss. Then, I use this created ss to find the loaded link names on the page to run eacxh seperate test.

The link ReportNames in the Excel ss show as:

WFI CONFIRMATIONS BY WFA ACCOUNT WFI_CONA
WFI PERFORMANCE REPORTS BY WFA ACCOUNT WFI_PERFA
WFI STATEMENTS BY WFA ACCOUNT (020/205) FUBS_ACCTB
WFI STATEMENTS BY WFA ACCOUNT (206) FSTA_ACCTB
WFI TAX DOCUMENTS BY WFA ACCOUNT WFI_TAXA
WFI STATEMENTS BY WFA ACCOUNT (021/200) FUBS_ACCTC
WFI STATEMENTS BY WFA ACCOUNT (201) FSTA_ACCTC

So, I would then manually need to change the link names to .Link("name:=WFI STATEMENTS BY WFA ACCOUNT \(020\/205\)?

Or could must I write a sript to look at each ReportName link and add the \ in front of each (, ), or / in the Excel ss?

thx so much.
Reply
#10
Solved: 10 Years, 9 Months ago
I did finally figure this out. It is call normalizing a string. Like Ankeh mentioned, I needed to place a \ in front of characters not recognized by QTP when it is in a link etc.

My link namesd change and contain all types of characters, those along with the number keys on the keyboard.

To normalized a string, I used Replace. My function is thus:

Code:
Public Function NormalizeString (OrgStr)

            Dim TempStr
            
            TempStr = Replace(OrgStr, "\", "\\")

            TempStr = Replace(OrgStr, "/", "\/")
            
            TempStr = Replace(TempStr, "*", "\*")
            
            TempStr = Replace(TempStr, "+", "\+")

            TempStr = Replace(TempStr, "(", "\(")

            TempStr = Replace(TempStr, ")", "\)")

             TempStr = Replace(TempStr, "=", "\=")

             TempStr = Replace(TempStr, "&", "\&")

             TempStr = Replace(TempStr, "@", "\@")

             TempStr = Replace(TempStr, "#", "\#")

             TempStr = Replace(TempStr, "_", "\_")

             TempStr = Replace(TempStr, "!", "\!")
            
            NormalizeString = Replace(TempStr, "?", "\?")
            
End Function
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,625 02-25-2014, 02:22 PM
Last Post: guin.anirban
  Finding the correct Link mv8167 2 4,288 01-24-2012, 07:58 PM
Last Post: mv8167
  Finding the correct WebTable mv8167 0 2,354 12-07-2011, 02:38 AM
Last Post: mv8167
  Finding WebElements mv8167 7 9,127 06-30-2011, 11:05 PM
Last Post: parminderdhiman84
  Finding a Link mv8167 4 5,363 06-21-2011, 07:04 PM
Last Post: mv8167

Forum Jump:


Users browsing this thread: 1 Guest(s)