Posts: 281
Threads: 116
Joined: Oct 2010
Reputation:
0
09-12-2011, 08:54 PM
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.
Posts: 424
Threads: 10
Joined: Aug 2011
Reputation:
0
09-13-2011, 01:05 PM
(This post was last modified: 09-13-2011, 01:10 PM by Ankesh.)
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.
Posts: 281
Threads: 116
Joined: Oct 2010
Reputation:
0
09-13-2011, 08:26 PM
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.
Posts: 107
Threads: 9
Joined: Apr 2011
Reputation:
0
09-14-2011, 08:15 AM
Hi...if you have more than 1 link in the same name, use index . plz do not use coordinates.
Posts: 281
Threads: 116
Joined: Oct 2010
Reputation:
0
09-14-2011, 07:56 PM
(This post was last modified: 09-14-2011, 07:57 PM by mv8167.)
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>
Posts: 424
Threads: 10
Joined: Aug 2011
Reputation:
0
09-15-2011, 11:11 AM
@ 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.
Posts: 281
Threads: 116
Joined: Oct 2010
Reputation:
0
09-15-2011, 06:36 PM
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.
Posts: 424
Threads: 10
Joined: Aug 2011
Reputation:
0
09-19-2011, 03:51 PM
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
Posts: 281
Threads: 116
Joined: Oct 2010
Reputation:
0
09-19-2011, 07:39 PM
(This post was last modified: 09-19-2011, 10:41 PM by mv8167.)
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.
Posts: 281
Threads: 116
Joined: Oct 2010
Reputation:
0
09-27-2011, 02:42 AM
(This post was last modified: 09-27-2011, 02:46 AM by mv8167.)
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
|