Friday, April 21, 2006

Useful Winrunner Steps

These steps are useful for performing several actions in WinRunner. The actions covered include:
Opening a New Test
Loading a GUI Map File
Creating compiled modules
Using a compiled Module
Starting a WinRunner session
Using the help system to find built-in function


Creating a New Test
1. Click on File->Open
[Note that several tests can exist in the Window.
You can view other loaded tests by clicking Window->'Name of the test'
You can close a test you are viewing by clicking File->Close
]
2. Verify that the GUI Map file you want to use is loaded by opening the GUI Map Editor and viewing the loaded GUI Map Files
3. If the GUI Map you want is not loaded, load it
[See Loading a GUI Map File]


Loading a GUI Map File
1. Open the GUI map editor by clicking 'Tools->GUI Map Editor'
2. Load the desired GUI Map file by clciking 'File->Open' and choosing the file on the file system
3. Close the 'GUI Map Editor' by clicking 'File->Exit'


Creating compiled modules
1. Open a new test
2. Insert your functions
3. Open the test properties dialog by clicking 'Test->Properties'
4. Set the test type to compiled module


Using a compiled Module
1. use the load function to load the compiled module
2. Invoke functions from the module wherever you need them
3. [Optional] Call the unload function to unload the module


Starting a Winrunner session
1. Launch the application
2. Open the GUI map editor by clicking 'Tools->GUI Map Editor'
3. Clear all existing content by clicking 'File-> Close All'
4. Load the desired GUI Map file by clicking 'File->Open' and choosing the file on the file system
5. Close the 'GUI Map Editor' by clicking 'File->Exit'


Using the help system to find built-in function
1. Load the help system by F1
2. Choose the Content tab
3. Choose 'Function by Category->Standard Function'
4. Select the desired group

Labels:

Monday, April 10, 2006

Logical Names

When QTP learns objects from your AUT and stores them into the object repository, it assigns a logical name to each of these objects. These logical names are used in the VBScript code that QTP generates whenever it records your actions. You may see code in your test pane (Expert View) that looks like:

VbWindow("frmMain").VbButton("btnSave").Click

In this case, two different objects are referenced, frmMain which is a container and btnSave which is an object within that container. frmMain and btnSave are both logical names that are stored within our object repository. They however didn't start out with names like these. You will learn by experience that QTP tries to guess unique names for each of the object. Uniqueness is important because 2 objects in the same scope (i.e. within the same container) cannot have the same name. QTP uses internal logic to decide on what the logical name for an object would be and if the name already exists, appends a numerical index to the name. The following names are examples of this:

VbEdit, VbEdit_1, Size:, Direction

You will notice that the format of these logical names and the specific objects they represent within the AUT are a little difficult to reconcile. These are just some of the problems the QTP naming scheme creates, though I should note that none of these names are difficult for QTP to use in a test. The challenges posed by this naming pattern includes:
* The logical name does not specify the type of object that exists
* The logical name does not help to identify the object in your AUT
* The logical name is difficult to reproduce because it contains symbols, spaces and special characters

Since our goal is to simplify the process of testing, it is therefore very advisable after adding objects into your object repository to rename the objects so that you solve all the problems described above. They are many useful naming conventions that you can use here, and it is often best to use the one you are most familiar with, or if you are on a team project to use the one described in the test plan. Remember that the goal of naming conventions is to promote universality among resources shared by many people.

I use a convention known as the objDescriptiveName naming convention. You may be familiar with this naming convention under a different name, the VB Naming Convention.

The convention has two parts

obj: A three letter prefix that specifies the generic type of the object
DescriptiveName: A descriptive name that makes it easy to identify the object on the screen

You will notice that using this convention, you will not have to use any special characters or symbols thus making it additionally easy to reference your object names in your test script. Special characters are notoriously difficult to use in names and many naming conventions do not accept them at all, once we start working on VBScript syntax, you will see that VBScript prevents the use of symbols and special characters as part of names for constants and variables.

QTP however allows us to use them for logical names. The problem with these though is that it is difficult to correctly recreate the following logical name.

"<- Today's Date:" For some, it might be difficult to see that there are 2 spaces between Today's and Date, but QTP sees this. You may also miss the fact that there is a colon after Date. QTP however will not miss this fact and anything you type that does not match exactly with what you have above will be considered incorrect. You will also notice that the first letter of every word in the objDescriptiveName convention starts with an upper case character. This is another benefit of the convention and it is done in order to make it easy for you to read the name of the object. As an example, will it be easier for you to read the following: btntodaysdate or btnTodaysDate While the first form is not impossible to read, you have to spend a little more time determining where word boundaries end and new words begin. The second form however is much easier to read, and it achieves this by marking the first character of each word in upper case. You will find below a list of prefixes that I will also use to specify the type of each of the objects. I have broken these into groups:

WINDOWS TEST OBJECTS

Prefix

Object

btn

cal

cmb

chk

dlg

drv

dtp

fra

frm

lbl

lst

lvw

mnu

nud

obj

opt

pic

prg

tkb

txt

Button

Calendar

ComboBox

CheckBox

Dialog

Drive Selector

Date Picker

Frame

Form

Label

ListBox

ListView

Menu Item

Numeric UpDown (Spinner)

Object

Radio (Option) Button

Picture Box

Progress Bar

Track Bar

TextBox


DATA TABLE OBJECTS

Prefix

Object

cpt

out

dat

Parametrized Checkpoint value

Output Value

DataTable parameter