Monday, January 9, 2012

QTP : Recording & Playback

Record and Playback are used to record the user actions in the form of scripts and Play them back at a later time by running the script.Using record option QTP users can build  automation scripts automatically without having any knowledge of scripting.Starting from the moment when Record button is clicked till the moment stop button is clicked QTP as a  records all the user actions as you navigate through your website or application and generates a script.User actions can be seen in the script as steps. A step is anything that user does that changes the content of a page or object in your application, like for example clicking a link or typing data in an edit box.

Recording Modes: There are three recording modes in QTP

  • Normal 
  • Analog
  • Low Level
(1) Normal Recording Mode: It records the actions performed by the user on the application objects like Edit boxes, List boxes and Links. QTP records each action as one step in the QTP script. Step is nothing but one line in the code.

Steps for Normal Recording Mode:
  1. Launch QTP
  2. Create a new test by selecting  File>New>Test
  3. Click Record button or select Automation>Record or press the Record command shortcut key F3.
  4. The Record  and Run settings dialog opens as shown below, Enter Application URL in the box as shown in our case it is "www.bing.com".

  5. When  you are done with recording click the Stop button or select Automation>Stop or press F4.
  6. Save Your Test.
  7. Run the test by clicking Run.


EXAMPLE: 
Perform the following steps on bing application.

  1. From bing home page, enter text " Syed Armani " in the search box.
  2. Click bing Search Icon.
  3. Click on the Linkedln link from the search results. 

    ( Script created in normal recording will appear as below in Keyword View )
         ( Script created in normal recording will appear as below in Expert View )

 In the above script we can observe the following object classes with names of objects as below:

Browser           Bing
Page                Bing, Syed Armani
WebEdit           "q"(search box)
WebButton       "go"
Link                 "Syed Armani|Linkedln"

(2) Analog Recording Mode: This mode enables you to record the exact mouse and keyboard operations you perform in relation to either the screen or the application window. This mode is useful when you want to
record mouse movements, for example recording a signature or drawing performed by dragging the mouse. To record in analog mode , first start normal recording then select Automation>Analog Recording. The Analog recording dialog box opens up as shown below.

                                  

  Record relative to the screen: QTP records any mouse movement or keyboard input relative to the top
  left coordinates of your screen(i.e. desktop).

  Record relative to the following window: QTP records any mouse movement or keyboard input
   relative to the coordinates of the specified window.


(3) Low Level Recording: Low level recording mode is used only when exact coordinate of the operation
     is essential.To record a test using low level recording mode, start the normal recording session then select
     Automation>Low Level Recording to start recording in low level.


                    
(code created in low level recording)
  • Window("Oracle VM VirtualBox Manager").Window("Create New Virtual Machine").WinObject("Cancel").Click 40,17

This code states that Cancel button was clicked at  coordinate 40,17. This coordinate is measured by taking top left corner of the object( Here it is the Cancel button) as reference (0,0).

Guidelines for choosing the recording mode:
  1. Use Analog recording mode only when normal recording mode does not accurately record your operations.
  2. Use analog recording for the applications in which the actual movement of the mouse is what you want to record,like drawings,signatures etc.
  3. Use low level recording when you need to record the exact location of the operation on your application screen.
Running Tests: QTP always run from the first step, unless you specify otherwise.To run a test , open it and select Automation>Run or press F5.The Run dialog box opens, in the dialog box specify the result location. Temporary run result folder saves run results in a temporary folder.This option overwrites any results previously saved in this folder. Click OK to start the Run session.

Test Result Window: When a run session ends, you can view run session results in the Test Results window. The run result tree is located in the left pane in the Test Result window as shown in figure below.

                    
 


Record and Run Settings Dialog: This Dialog box is used to instruct QTP , which application to open when you begin to record or run your test.
  • Windows Application Tab: As shown in figure below.There are two radio buttons, if we select first one QTP records and run test on any application and if we select a second one, we can specify the applications on which QTP should record or run test.

                           

    • Checkbox Application opened by QuickTest indicates that QTP records only on those applications opened from QTP.
    • Checkbox Application opened via the Desktop indicates that QTP records only on those applications opened by double clicking on the application icon placed on the Desktop.
    • Checkbox Application specified below indicates that QTP records only on those applications
      selected using icon.
  •   Web Tab: Web Tab as shown below also have two radio buttons, if select the first one,QTP
       records and run test on application opened on any browser and if we select the second one, QTP
       records and runs tests by opening application in a new browser of the specified type.

            
  NOTE: QTP RUNS TEST ON ANY SUPPORTED BROWSER BUT RECORDS ONLY ON     MICROSOFT INTERNET EXPLORER.  
                                






***************************************************************************************************************************
" Success often comes to those who dare and act. It seldom goes to the timid who are ever afraid of consequences."
******************************************************************************************************************************











3 comments:

  1. Hai,

    i tried to open www.bing.com via QTP for record and play as you mentioned above. But, Wen i start recording , Internet Explorer stopped working.

    How to resolve it. Please provide some solutions.


    Thank You,
    Danikadain

    ReplyDelete
  2. Install qtp patch for internet explorer

    ReplyDelete
  3. Dear All,
    can any of you please help me out that in normal recording mode qtp recording coordinates of the firefox brouser.
    How can i fix it?
    Note: Analog recording and low leverl recording both of the buttons not clicked.

    ReplyDelete