Micro Focus QTP (UFT) Forums
How to get all links in a page - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to get all links in a page (/Thread-How-to-get-all-links-in-a-page)



How to get all links in a page - iamsekhar - 08-26-2010

Scenario:
In my application there are many links, by clicking each and every link the
1. Click the hyperlinks
2. Then "File Download" dialouge appears we have to save file name in any drive (C or D)
2. After saving file then get row count in xls file.

Note: I have done above scenario by recording and writing script, it was working without any issues. Refer below code FYI

I have many kind of scenarios to validate xls row count. Is there any other way to write code optimization like function or Descriptive programming? Kindly suggest your approach.
Please refer below code FYI

Code:
Window("Lilly Science Grid").Page("Page_3").Link("25").Click    // clicking link
wait(2)
rowCnt = Window("Lilly Science Grid").Page("Page_3").Link("25").GetROProperty("text")
convLng = CLng(rowCnt)
msgbox rowCnt
wait(3)
SwfWindow("Lilly Science Grid").Dialog("File Download").Click 285,18  // QTP generated script
SwfWindow("Lilly Science Grid").Dialog("File Download").Activate // QTPgenerated script
SwfWindow("Lilly Science Grid").Dialog("File Download").WinButton("Save").Click //
wait(5)
Dialog("Save As").Activate
Dialog("Save As").WinEdit("File name:").Set "D:\tumo.xls"
Dialog("Save As").WinButton("Save").Click
Dialog("Save As_2").WinButton("Yes").Click
Dialog("Download complete").Click 321,184
Dialog("Download complete").WinButton("Close").Click

fileName = "D:\tumo.xls"
Set xlObj = CreateObject ("Excel.Application")
Set wBook = xlObj.workBooks.Open(fileName)
Set sheetName = wBook.worksheets("Sheet1")
'Set sheet = xlObj.ActiveWorkbook.worksheets("sheet1")
column_count = sheetName.usedrange.columns.count
row_count = sheetName.usedrange.rows.count
xlsRowCnt = row_count -1
msgbox xlsRowCnt

If xlsRowCnt = convLng Then
reporter.ReportEvent micPass, "Row Count Validation","Row Count matching with column header. Step.Pass"
else
reporter.ReportEvent micFail, "Row Count Validation","Row Count is not matching with column header.Step.Fail"
End If
wBook.close

Thanks for your help.
Sekhar