-->Script Creation

QTP Considers every thing in an application as an OBJECT.
For easy understanding and writing a script this example will help you.
Each OBJECT belongs to a CLASS. Each CLASS has a PROPERTY. Each PROPERTY has VALUE.
For ex: Here i describe a Mango with respective to QTP
Mango is an OBJECT
It belongs to CLASS Fruit
It has a PROPERTY color
It has VALUE Yellow. This is how the qtp recognizes the Mango.

The script in QTP can be created in 3 ways
1. Using the Recording option
2. Using step generator
3. Manually writing the script

QTP provides 3 types of recording methods
1. Normal Recording or General Recording or Context sensitive Recording (Default one)
2. Analog Recording
3. Low-Level Recording

Normal Recording:
In this method of recording, qtp Records the user command actions like activating a window, minimizing or restoring a window, setting a value to text box, selecting an item form Combo box or list box, click on a button, etc.
Steps to perform Normal Recording:
1. Ensure that record and run setting are provided
2. Click on Automation(from menu) --> Record\F3
3. Perform required navigation's on the application
4. Click on stop recording\ Select Automation --> stop\F4

Analog recording:
In this method of recording, qtp records the mouse moments, keyboard operations, apart from user command actions, in relation to either the screen or the application window. This type of method is used to automate digital signatures, CAD/CAM, MS paint etc..
Steps to perform Analog Recording:
1. Ensure that record and run setting are provided
2. Click on Automation(from menu) --> Record\F3
3. Select Automation --> Analog Recording
4. Select the option to record relative to the screen or relative to the window
5. Click on hand icon and select the window
6. Perform required navigation's on the application
7. Click on stop recording\ Select automation stop\ F4
Note: You cannot edit Analog Recording steps from within QuickTest.
You can record in Analog Recording mode relative to the screen or relative to a specific window.
When you are finished and want to return to normal recording mode, click the Analog Recording button or choose Automation > Analog Recording to turn off the option.
If you chose to Record relative to the screen, QuickTest inserts the RunAnalog step for a Desktop item. For example:
Desktop.RunAnalog "Track1"
If you chose to Record relative to the following window, QuickTest inserts the RunAnalog step for a Window item. For example:
Window("Microsoft Internet Explorer").RunAnalog "Track1"
The track file called by the RunAnalog method contains all your analog data and is stored with the current action.

Record relative to a specified window
If the operations you perform are on objects located within one window and that window does not move during the analog recording session. This ensures that during the run session, QuickTest will accurately identify the window location on which the analog steps were performed even if the window is in a different location when you run the analog steps. QuickTest does not record any click or mouse movement performed outside the specified window. When using this mode, QuickTest does not capture any Active Screen images.
Record relative to the screen
If the window on which you are recording your analog steps moves during recording or if the operations you perform are on objects located within more than one window. This can include dragging and dropping an object from one window to another. When using this mode, QuickTest captures only the Active Screen image of the final state of the window on which you are recording.

Low-Level Recording:
This method is used, if an object is not identified with normal recording or analog recording. In case of low level recording QTP identifies the object using the Co-Ordinates(x, y, width, height) and it provides minimum set of methods to work with objects.
This mode records at the object level and records all run-time objects as Window or WinObject test objects. You can also use low-level recording if the exact coordinates of the object are important for your test.
Note: Steps recorded using Low Level Recording mode may not run correctly on all objects.
Steps to perform Low-Level Recording:
1. Ensure that record and run setting are provided
2. Click on Record button\ Select automation record option from menu\ F3
3. Select automation low-level recording
4. Perform required steps on the application (AUT)
5. Click on stop recording
When you are finished and want to return to normal recording mode, click the Low Level Recording button or choose Automation > Low Level Recording to turn off the option.
->Use analog recording or low-level recording only when normal recording mode does not accurately record your operation.
->Analog recording and low-level recording require more disk space than normal recording mode.
->You can switch to either Analog Recording or Low Level Recording in the middle of a recording session for specific steps. After you record the necessary steps using analog recording or low-level recording, you can return to normal recording mode for the remainder of your recording session.
When you are finished and want to return to normal recording mode, click the Low Level Recording button or choose Automation > Low Level Recording to turn off the option.

Difference between the same operations recorded using normal mode and Low Level Recording mode.
Suppose you type the word mercury into a user name edit box and then click the Tab key while in normal recording mode. Your test is displayed as follows in theExpert View:
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").Set "mercury"
If you perform the same action while in Low Level Recording mode, QuickTest records the click in the user name box, followed by the keyboard input, including the Tab key. Your test is displayed as follows in the Expert View:
Window("Microsoft Internet Explorer").WinObject("Internet Explorer_Server").Click 564,263
Window("Microsoft Internet Explorer").WinObject("Internet Explorer_Server").Type "mercury"
Window("Microsoft Internet Explorer").WinObject("Internet Explorer_Server").Type micTab

Steps to work with Step generator:
1. Ensure that required objects are added to the OR
2. Place the cursor in the expert view, where a step needs to be generated
3. Select insert from Menu -> Step generator\ F7
4. Click on select object icon -> select the requires object -> if the object is not available -> click on the hand icon -> Click on the object from the application
5. Select the method name or operation -> Provide the value, if required -> Click on OK
6. Repeat for all the steps of Test scenario

Steps to create the script manually:
1. Add all the required objects to the OR
2. Spy on the parent object and view it’s class name
3. Spy on the child object and view it’s class name
4. In QTP Script editor (Expert View), use the following syntax to understand.
* Parent object class name (“Name”) Child object class name (“Name”), Method “Value”