Finding Links with Paren's - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Finding Links with Paren's (/Thread-Finding-Links-with-Paren-s) Pages:
1
2
|
Finding Links with Paren's - mv8167 - 09-12-2011 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) In my code I use the following to click on the link. Code: ReportName = objDriverSheet.Cells(r,4). 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. RE: Finding Links with Paren's - Ankesh - 09-13-2011 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 try the below descriptive programming 'Description for Browser and page Code: Set objBrowser=Description.create and Use the Below code Code: Browser(ObjBrowser).Page(ObjBrowser).Frame(ObjFrame).Link(ObjLink).Click I hope this would work. RE: Finding Links with Paren's - mv8167 - 09-13-2011 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. RE: Finding Links with Paren's - vIns - 09-14-2011 Hi...if you have more than 1 link in the same name, use index . plz do not use coordinates. RE: Finding Links with Paren's - mv8167 - 09-14-2011 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> RE: Finding Links with Paren's - Ankesh - 09-15-2011 @ 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. RE: Finding Links with Paren's - mv8167 - 09-15-2011 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" 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" again, thx for your help. RE: Finding Links with Paren's - Ankesh - 09-19-2011 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 RE: Finding Links with Paren's - mv8167 - 09-19-2011 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. RE: Finding Links with Paren's - mv8167 - 09-27-2011 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) |