Sunday, December 9, 2012

Synchronization in QTP



Synchronization : 

                 Synchronization is a process to make the Automation tool(QTP) wait for the application process to complete prior to moving to subsequent steps.
How can we  achieve this,  it can be done in the following ways.
             1. Using Waitproperty method
    2. Browser Navigation timeout.
    3. Object Synchronization timeout
    4. Inserting the  Wait/Exist statement
 *********************************************************************************************
Using Waitproperty method :
*********************************************************************************************
Syntax :
Browser(“Google”).Page(“Google”).WebEdit(“q”).waitproperty(PropName,PropValue,TimeInMilliSeconds)


*********************************************************************************************
 Browser Navigation timeout:
*********************************************************************************************
       Default Browser Navigation timeout is 60 seconds, means if QTP unable identify the Unique browser
object it wait for 60 seconds
*********************************************************************************************
 Increasing the Object Synchronization timeout:
*********************************************************************************************
              Default  object Synchronization timeout is 60 seconds, means if QTP unable identify the Unique object it wait for 60 seconds
*********************************************************************************************
Inserting the  Wait/Exist statement :
*********************************************************************************************
Syntax for wait:
      Wait time in seconds
Syntax for Exist
    Browser(“Google”).Page(“Google”).WebEdit(“q”).exist(5)
****************************************************************************************
Diff : Wait is static and Exist is dynamic
****************************************************************************************





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

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