(08-24-2010 10:01 AM)venkatbatchu Wrote: [ -> ]Hi Sekhar,
The above script which i given is with out giving any file name while saving.
1.First click the Save button (Browser("xxx").Dialog("xxx").Winbutton("xxx").Click
2. Here you will not be knowing what is the file name which you have saved.
3. The above file will be saving in specific folder( My assumption: Here file name is dynamically varying but folder name is constant, i.e all files are by default saving in same folder)
4. By usin this folder you can find out the last modified file name i.e the last file which you have saved.
5. Now you know what is the last modified file i.e file which u saved recently
6. You will come to know what is the last modified file is by using the above script
7. Once u come to know then import the file to datatable i.e Datatable.Import "file name" this file name is the one whic u got it from script
8. After importing find the row count by using Datatable.GetRocount
Finally u will be having Rowcount in that particular Excel file.
Please let me know for further clarification.
Regards,
Venkat.Batchu
Hi Venkat,
Thanks for your reply with detailed steps. Its really very great for your help. Requirement is slight changed, because we have to save file name in any drive (C or D) and give the name for xls and pass this excel file for row count. I have done in the following way. It is working but i am not sure this is correct coding practice or not?
One more Question: I have many this 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.
Thanks for your help. Please refer below code FYI
Window("Lilly Science Grid").Page("Page_3").Link("25").Click
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
SwfWindow("Lilly Science Grid").Dialog("File Download").Activate
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