Micro Focus QTP (UFT) Forums

Full Version: How to get all links in a page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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