Tuesday, July 31, 2012

Recovery Vs On error Resume Next

*********************************************************************************
What is Recovery and  On error Resume Next?
*********************************************************************************
        Recovery scenario mechanism  and On error Resume Next both are used to avoid the effect
of unexpected errors caused by the application as well as script

*********************************************************************************
Why Recovery and On error Resume Next?
*********************************************************************************
         As automation test engineer we need to develops the scripts such away that scripts shouldn' t effect  even if any unexpectd error occurs

*********************************************************************************
Genaerally while executing scripts we may get two types of unexpected errors

1)Error From application
2)Error From Script

*********************************************************************************
How to handle the Error in the application?
*********************************************************************************
                      To handle the Unexpected errors in application we will use QTP recovery scenarios mechanism or by VB script if else condition

*********************************************************************************
How to handle the Error in the Script?
*********************************************************************************
            To handle the Unexpected errors in script we will use VB script On error resume next

*********************************************************************************


On error Resume Next

**********************************************************************************
Why On Error Resume Next:
**********************************************************************************
To avoid the unexpected errors caused by the script

**********************************************************************************
What "On Error Resume Next" will do?
***********************************************************************************
These Statment will supress the error produced by the script and resumes the next step

***********************************************************************************
On Error Goto 0
***********************************************************************************
These will be helpful to disabled the Activated On error resume next statement

***********************************************************************************
Err Object :
***********************************************************************************
In VB Script every single statement will produce the Error number,if it is Zero stament is correct else statment is false

***********************************************************************************
To get the error number :
***********************************************************************************
msbox Err .number

***********************************************************************************
To get the error Description:
***********************************************************************************
msgbbox Err.Description

***********************************************************************************
To clear the error:
***********************************************************************************
Err.Clear

Note: When We get the error number through Err object, we should explicitly clear the error number,otherwise script will carries only one number
***********************************************************************************
To raise the error:
***********************************************************************************
Err.Raise

***********************************************************************************
Note : On Error Resume Next will handle the only Script error not application errors
***********************************************************************************





Monday, July 30, 2012

Run Modes

************************************************************************************
Run Modes:
************************************************************************************
Run modes are three types

1)Normal Run
2)Fast Run
3)Update Run
************************************************************************************
Normal :
************************************************************************************
           Displays execution marker for showing the current execution step.
************************************************************************************
Fast :
************************************************************************************:
            Execution will be faster than the normal run mode,even it won’t show the execution marker
************************************************************************************
Update :
************************************************************************************           QTP is having Update Run mode for updating test object descriptions, the expected checkpoint values, and/or the Active Screen images and values.
************************************************************************************
Note : Update run mode doesn't update parameterized values like Data Table data and environment variables.
************************************************************************************

Saturday, July 28, 2012

QTP Environment Variables


Why Environment Variables:

1)We can get the information related to OS(Operating System),test name, testpah & result path
2)We can share the data across the actions like global variables
*********************************************************************************
Environment Variables are two types:
*********************************************************************************
1)Built in 
2) User Defined

*********************************************************************************
Built in :
*********************************************************************************                                    These are the variables which we can't modify at any time


Example: 

To get the test path
msgbox environment.Value("TestDir")


To get the OS name
msgbox Environment.Value("OS")


To get the HostName:
msgbox Environment.Value("LocalHostName")


*********************************************************************************
User defined Env Variables:
*********************************************************************************
      Here user can create the variables depend on the requirement


Again these are two types


1)Internal
2)External


Internal :
     If user is defined the variables with in QTP that variable are called the Internal Variables
External :
     Even User can define the Varibles outside the QTP i.e XML, these variables we can import into QTP called External variables


*********************************************************************************
Note :We can export the Internal variables into XML file
*********************************************************************************















Recovery Scenarios


 Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps:

  • Triggered Events
  • Recovery steps
  • Post Recovery Test-Run
*******************************************************************************
Triggered Events:
*******************************************************************************
Popup Window:
QuickTest detects a pop-up window and identifies it according to the window title and textual content.

Object State:
QuickTest detects a specific test object state and identifies it according to its property values and the property values of all its ancestors.

Test Run Error:
QuickTest detects a run error and identifies it by a failed return value from a method

Application Crash:
QuickTest detects an application crash and identifies it according to a predefined list of applications.

*******************************************************************************
Recovery
*******************************************************************************


Select type of recovery operation and click on next.
Keyboard or mouse operation:
                QuickTest simulates a click on a button in a window or a press of a keyboard key. Select this option and click on Next to continue to the Recovery Operation.

Close application process:
                  QuickTest closes specified processes. Select this option and click on Next to continue to the Recovery Operation – Close Processes Screen.

Function call:
                QuickTest calls a VBScript function. Select this option and click Next to continue to the Recovery Operation – Function Call Screen.

Restart Microsoft Windows:
                QuickTest restarts Microsoft Windows. Select this option and click Next to continue to the Recovery Operations Screen.

*******************************************************************************
Post Recovery
*******************************************************************************

 Repeat Current Step and Continue:
                     Repeats the current step is the step that QuickTest was running when the recovery scenario was triggered.

 Proceed to next step:
                  This will skips the step that QuickTest was running when the recovery scenario was triggered.

 Proceed to next action or component iteration:
                  Goes to next action iteration after completion of recovery operation.

 Proceed to next test iteration:
                  Goes to next test iteration after completion of recovery operation.

 Restart current test run:
                 To restart the testrun after completion of recovery operation.

 Stop the test run:
                 To Stop the Entire Test Run.

******************************************************************************************************************************************************************

Difference between Dim and Redim

*********************************************************************************
Dim :
************************************************************************  ***
Dim is used to  declare the variables
*********************************************************************************
Redim : 
*********************************************************************************
 Redim Is used to re size the array variables
*********************************************************************************
Preserve :
*********************************************************************************
Preserve is the word we can preserve the last array values
*********************************************************************************


Example:

Dim a()

ReDim a(3)

a(0) = "1"

a(1) = "2"

a(2)= "3"


Redim preserve a(5)

a(3) = "14"

a(4) = "15"

*********************************************************************************
Note: if we are using redim statement with out preserve key, it will not preserve the previous array value & will creates fresh array
*********************************************************************************

Working with System Environment variables

 
System Environment variables are two types

1)User Variables
2)System Variables

*********************************************************************************
User  Variables :
*********************************************************************************
          In user specific, user or admin can declare the variables

Syntax:


Set Obj = CreateObject("wscript.shell")
set objEnv = Obj.Environment("User")
sUserName = objEnv.Item("UserName")  'these variable should be declare in User environment variables

*********************************************************************************
System  Variables :
*********************************************************************************
         In System specific only admin can declare the variables

  Syntax:


  Set Obj = CreateObject("wscript.shell")
  set objEnv = Obj.Environment("System")
  sUserName = objEnv.Item("UserName") 'these variable should be declare in System environment variables

*********************************************************************************

Adv of Automation


  •  Avoid the errors that human make when they get tired after multiple repetitions.
  • The test program wont skip any test by mistakes.
  •  Each feature test cycle will take less time & Required less
  •   human intervention.
  •  Required for Easy cycle of Regression Testing.

Working with WebTable


Below are the methods to work with Webtable

*********************************************************************************
ChildItem:
*********************************************************************************

This method is to access child objects from a web table cell in web table object without using description object.

EX:

Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").ChildItem(r,c,"WebEdit",index)

*********************************************************************************
ChildItemCount:
*********************************************************************************
           Returns the number of objects of a specific class type in the specified cell.

EX:

Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:"). ChildItemCount(r,c,"WebEdit")

*********************************************************************************
GetCellData :
*********************************************************************************
This method is to retrieve data specific row and column from webtable.

EX:

Browser (“Browser").Page (“Page").Frame ("Frame_3").WebTable ("Job ID_2").GetCellData (3, 5)

*********************************************************************************
GetRowWithCellText:
*********************************************************************************
This method is to retrieve the row number based on text which is present in webtable cell.

EX:

Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebTable("Yahoo! ID:").GetRowWithCellText(“Text”)
*********************************************************************************




Object Identification


Every test automation tool is GUI (graphical user interface)sensitive. Test automation tool has to identify the objects on the application, then only it can do the intended operations.
QuickTest Professional has its own mechanism to identify the objects on the Application Under Test. QTP has various add-ins available for different applications. Let us have a look at the QTP’s object identification mechanism.

QTP identifies the objects with the following properties:
  1. Mandatory properties
  2. Assistive properties
  3. Smart identification
  4. Ordinal identifier
Location
Index
Creation time(only for browser object)

QTP identifies the objects with Mandatory properties, if the object does not contain these properties then it will go ahead with the Assistive properties. If both are absent (not added to Object Repository as they are absent for a particular object) then it uses either smart object identification (if enabled) or Ordinal Identifiers (location or index of an object).

Thursday, July 26, 2012

FileSystemobject


**********************************************************************************
FileSystemobject
**********************************************************************************

As part of our automation Some times we need to interact with text files,folders & Drives,these we can done using filesystemobject

**********************************************************************************
CreateTextFile:
**********************************************************************************
Description :We can create the new file

Syntax:
Set FSO = createobject("scripting.filesystemobject")
set Fpt = FSO.CreateTextFile(Pathoftextfile)

**********************************************************************************
OpenTextFile:
**********************************************************************************

Description : We can call the Existing file

Syntax:
Set FSO = createobject("scripting.filesystemobject")
set Fpt = FSO.OpenTextFile(Pathoftextfile)

 **********************************************************************************
Read all :
**********************************************************************************
Description :Usign readall we can read the all data from the text file

Syntax:
Set FSO = createobject("scripting.filesystemobject")
set Fpt = FSO.CreateTextFile(Pathoftextfile)
Fpt.Readall

**********************************************************************************
Readline :
**********************************************************************************
Description : Using readline we can read the line from the text file

Syntax:
Set FSO = createobject("scripting.filesystemobject")
set Fpt = FSO.CreateTextFile(Pathoftextfile)
Fpt.Readline

**********************************************************************************
WriteLine :
**********************************************************************************
Description : Using WriteLine we can write the data to text file
Syntax:=
Set FSO = createobject("scripting.filesystemobject")
set Fpt = FSO.OpenTextFile(PathOfTextFile)
Fpt.WriteLine "QTP"

**********************************************************************************
Below are the some more methods to work with text files & folders
**********************************************************************************


DeleteFile

FileExists

CopyFile

MoveFile

CreateFolder

DeleteFolder

FolderExists

CopyFolder

MoveFolder

GetFileVersion
**********************************************************************************





Actions in QTP


******************************************************************************
Actions

******************************************************************************

Action is the concept from QTP,using which we can implement the modularity    

There are totally 3 three types of Actions:

 1.Reuabale action.
 2.Non reusbale action.
 3.External action
   default one is the non resubale action.
******************************************************************************
Non-reusable Action:
       The action which can't be called by any other test apart from the one in which it is created.
Reusable Action: 
    An action which can be called by any number of tests
External Action:

     This is a reusable action, which can't be modified in any other test. It can be just called and
used...

******************************************************************************
 Calling actions:

Call to copy action:
    if we are calling action with these option, the created action we can modify in the called test

 Call to existing actions : 
     if we are calling action with these option, the created  action we can't modify in the called test
******************************************************************************
Spliting Actions:
   We can Split an action into two actions
SplitAction Types:

Nested Action :
    If we split an action with Nested option,created two actions will be depedent to each other

Independent Action :
   If we split an action with Indepedent option,created two actions will be indepedent to each other
******************************************************************************

Q)Can we Merge two actions?
  No
******************************************************************************

Q) What is the difference between attheendoftext and ofterthecurrentstep?

  Generally while creating newaction qtp will ask for above two option
  if we are selecting "attheendoftext" option,the created new actions will be the  indepedent to current action
  if we are selecting "ofterthecurrentstep" option,the created new actions will be the  depedent(nested) to current action
******************************************************************************

Q)if we split one action,the respetive action object repository will be split or not?
  No.
******************************************************************************





Wednesday, July 25, 2012

List of QTP Utility Statments


List of QTP utility Statements:

  • DescribeResult Statement
  • ExecuteFile Statement
  • ExitAction Statement
  • ExitActionIteration Statement
  • ExitComponent Statement
  • ExitComponentIteration Statement
  • ExitTest Statement
  • ExitTestIteration Statement
  • GetLastError Statement
  • InvokeApplication Statement
  • Print Statement
  • RegisterUserFunc Statement
  • RunAction Statement
  • SetLastError Statement
  • UnregisterUserFunc Statement
  • Wait Statement

 In next Post i will give the brief detials about above statments

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. Inserting the synchronization point.
    2. Increasing the Browser Navigation timeout.
    3. Increasing the Object Synchronization timeout
    4. Using Browser Sync method    
    5. Inserting the  Wait/Exist statement.

  Synchronization Point :
  •  One can Insert a Synchronization point during a recording session on an application object and ensure the tool waits for the object to get fully functional prior to  continuing with subsequent steps.
  • One can insert a Synchronization Point by navigating to Insert -> Synchronization  Point , using the  Hand Icon to select an object on the application window.
  • Select a Property Name for this object for which synchronization is to be defined.
  • Once the synchronization point is defines, a waitproperty statement gets generated  in the expert view and  an operation with waitproperty in the keyword view.
  • Increasing the Browser Navigation timeout  would enable QTP to wait for the browser to navigate to the desired webpage.
  •  Increasing the Object Synchronization timeout would enable QTP to wait for the objects on the UI  to appear .
     Both the Above properties are accessible by navigating through File -> Settings tab.
  • Sync : Used to make QTP wait for  application to navigate to a specified page.
  • Wait : This would make QTP wait for the time specified in the wait statement.
  • Exist : This would make QTP wait for the time specified in the exist statement till the object exist or the time gets elapsed.

Tuesday, July 24, 2012

What is ROI in automation?


ROI(Return On Investment)

Automated software testing invariably sounds good to IT quality assurance (QA) managers. Intuitively, you see that creating an automated test one time and then running it hundreds or thousands of times will enable you to expand test coverage, find defects earlier, and focus manual test effort where it is really needed. That has to save the company money and reduce business risk, right? But when you submit budget requests for test automation software or services, chief financial officers (CFOs) want more. They evaluate every expenditure based on how much money it will make or save the company, so you must show them what returns the
company can expect on the investment.

Environment needs for QTP


System Requirement     : IBM-PC (or) Equivalent to P3
Hardware Drive              : 250MB of Free Memory space
RAM                                 : 256MB of RAM
OS                                     : M/S windows 2000 server with 3-4 service pack
                                            

Friday, July 20, 2012

QTP concepts

Hi All, i am going to intiate the blog creation for qtp concepts..this should be useful for beginners as well as Professionals.Please share your ideas if any


Thanks,
Gkchowdary A