Saturday, December 8, 2012

Working with Excel Object



'****************************************************************************
''To Read The Data From Excel
'****************************************************************************

Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Workbooks.Open "C:\TestData.xls"
Set WorkSheet = ExcelObj.Sheets.Item(1)
sUserName= WorkSheet .Cells(2,1)
sPasswd = WorkSheet .Cells(2,2)
sKeyWord = WorkSheet .Cells(2,3)
ExcelObj.ActiveWorkbook.Save
ExcelObj.Application.Quit

'****************************************************************************
''To Write the Data into Excel
'****************************************************************************

Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Workbooks.Open "C:\TestData.xls"
Set WorkSheet = ExcelObj.Sheets.Item(1)
WorkSheet .Cells(i,1) = "Pass"
WorkSheet .Cells(i,2) = "Remarks"
ExcelObj.ActiveWorkbook.Save
ExcelObj.Application.Quit

'****************************************************************************
'To Count the Row & columns
'****************************************************************************

Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Workbooks.Open "C:\TestData.xls"
Set objUsedRange = ExcelObj.Worksheets(sSheetIndex).UsedRange()
msgbox objUsedRange.rows.Count
msgbox objUsedRange.Columns.Count
ExcelObj.ActiveWorkbook.Save
ExcelObj.Application.Quit

'****************************************************************************
'****************************************************************************

Sunday, October 7, 2012

How delete the cookies,temporary Internet files and browsing history using qtp?

************************************************************
To clear the Cookies
************************************************************
Web applications uses cookies to store user related information. While testing these cookies might interfere with the results of test. It is recommended to delete cookies before starting new test.


  • Using QTP Webutil object  we can delete the cookies
  • Webutil is the undocumented object in the QTP

WebUtil.DeleteCookies()

*******************************************************************
To clear temporary Internet files:
*******************************************************************
Set WshShell = CreateObject(“WScript.Shell“)
WshShell.run “RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

*****************************************************************************************
To Clear Browsing History
*****************************************************************************************
Set WshShell = CreateObject(“WScript.Shell“)
WshShell.
run “RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1″