Monday 30 July 2012

Checkpoints in QTP

Check point is a verification point, it takes expected result from the user and compares with actual results during execution and provides test results. 

There are 11 Checkpoints available in QTP: 

1.      Standard check point

2.      Text check point

3.      Text area check point

4.      Bit map check point

5.      Data base check point

6.      Accessibility check point

7.      XML Check point (from Application)

8.      XML Check point (from Resource)

9.      Page check point

10. Image checkpoint

11. Table checkpoint  

Note 1: From 6 to 11 checkpoints are only for Web. 

Note 2: From 9 to 11 checkpoints are hidden checkpoints, we can insert these checkpoints through standard checkpoint.

1.    Standard Checkpoint:  

It checks object property values. We can use this checkpoint for checking any property value.  

Navigation for Inserting standard checkpoint 

Keep tool under recording mode > place cursor in desired location > Insert > check point > Standard checkpoint > Show the object  > click okay > select property and enter expected results & click Ok and stop Recording. 

Navigation for Editing standard checkpoint 

Select Checkpoint statement and right click > choose checkpoint properties option > modify the value > click Ok. 

Navigation for Deleting standard checkpoint: 

Select Checkpoint statements and right click > choose delete option. 

Inserting Standard check points through active screen: 

View > Active Screen >place cursor in desired location >Place mouse pointer on active screen & right click> choose insert standard checkpoint option > click ok > enter expected result > click ok 

Note: Inserting Standard check points through keyword view same as in expert view. 

Note: We can insert standard checkpoints in 3 ways. 

a.      Through expert view,
b.      Through keyword view,
c.      Through Active screen. 

2) Text Checkpoint: 

 It Checks object’s text property value in different ways.  

Navigation:

Keep tool under Recording mode >Insert menu > checkpoint > Text checkpoint > Show the object > click ok > Select options 

(Match case; ignore spaces, exact match, text not displayed.) 

We can select one or more options > click ok & stop Recording. 

3)  Text Area Checkpoint:  

It checks the text area present in the application.  

Navigation:

Keep tool under Recording mode > Insert menu> Checkpoint > Text area checkpoint > Mark the area of text > select one or more options  

(Match case, ignore spaces, exact match, text not displayed.) 

Click ok and stop recording.


4.      Bitmap checkpoint:

It compares bitmaps; we can compare complete bitmaps as well as part of the bitmaps. 

Navigation:

Keep tool under Recording mode > Insert menu > Checkpoint > Bitmap checkpoint > show the Bitmap >click ok >select “check only selected area” option if we want to compare part of the bitmap > click ok >stop recording. 

5.      Database checkpoint: 

It checks Content of the back end Database. 

Navigation:

Insert > checkpoint > Database checkpoint >choose “specify SQL statement manually” option >click next > click create > select machine data source > Select DSN (QT_flight32) > click ok > enter SQL statement (select * from orders) > finish > click ok. 

Note: here we do not need to put tool under Recording mode and we do not need AUT since data is from backend.

6.      Accessibility check point: 

It checks whether the webpage in our web application is developed according to W3C (World Wide Web consortium) Rules and Regulations or not. 

It is a configurable checkpoint, according to our requirements, we can customize. 

Configuring accessibility checkpoint:  

Tools menu> options >web > advanced > check/uncheck items > click apply > click ok 

Invigilation:

Keep tool under recording mode with web environment >insert>checkpoint>accessibility checkpoint>show the webpage>click ok>click ok>stop recording. 

Result Criteria:

a1)     If item is available but not according to W3C rules then fail.

b2)     If an item is available, according to W3C rules then Pass.

c3)     If an item is not available then result would be pass 

7. XML Check point (from Application) 

It checks content of the XML file. 

Navigation:

Keep tool under Recording mode in web environment > insert menu > checkpoint (from application)> show the xml pages >click ok > stop Recording. 

8. XML Check point (from Resource)

It checks content of the XML file. 

Navigation: Insert menu > checkpoint >xml checkpoint (from resource) > browse path of the XML File > click ok > click ok. 

Note: 1. If XML file is an individual and path available, and then we can go for inserting xml checkpoint from resource. 

Note: 2. If XML file is part of web application, separate path is not available then we can choose inserting XML checkpoints from application.

9. Page checkpoint: 

It checks number of Links, Images and Loading time in a web page. 

It is a hidden checkpoint; we can insert this through standard checkpoint. 

Navigation:

Keep tool under Recording mode with web environment > Insert menu > checkpoint > Standard checkpoint >show the web page > click ok > click ok > stop recording.

110. Image checkpoint: 

It checks Image property values. 

Navigation:

 Keep tool under Recording mode with web environment > Insert menu > checkpoint >standard checkpoint > show the image > select image > click ok > click ok >stop recording.

111. Table checkpoint: 

It checks content of the web tables. 

Navigation: Keep tool under Recording mode under web environment > Insert menu > checkpoint > standard checkpoint >show the web table > click ok >stop recording. 

Debugging Tips in QTP

Debugging is a process of executing the script or a program in a User designed fashion with some temporary break points in order to identify the errors.

For debugging, QTP is providing debug commands and breakpoints. 

Debug Commands:


1    1)  Step Into (short cut key F11): 

  1. It starts execution
  2. It executes one statement at a time.
  3. If it is function call, it opens the function, after that it executes one statement at a time.

  2) Step Over (Short cut key F10):  

     a) It executes one statement at a time after execution starts

b) It executes all functions statements at a time

      Note: After opening the function, if we use step over it executes one statement at a time only.



     3)  Step Out (shift +F11): 

It executes all remaining statements in a function at a time. 

Ex: Dim a,b,c

a=100

b=200

c=a+b

msgbox c

msgbox "hello"

Call hyderabad

msgbox "bye bye" 

Note: Create a script and work on it 

Break Point: 

This feature is used for breaking the execution temporarily. 

Navigation:

Place cursor in desired location >Debug menu>Insert/Remove break point 

Or

Use short cut key (F9)

Or

Place mouse pointer before the statement and click. 

Note: If we want to execute Some part of the Test Script at a time and some other part of the test script step by step, there we can use breakpoints.  

Debug viewer Pane:  

It is used for viewing, modifying or setting the value of the variables during the execution break with the help of 3 Tabs.

    1. Watch
    2. Variables
    3. Command
Note: Through Debug Viewer Pane, We can watch variables whether the variables are taking correct values or not at a specific point of time. We can change Values of Variables temporarily.


Ex :

Dim x,y,z

x=10

y=20

z=x+y

msgbox z

msgbox "Hello"

x=35

y=67

z=x*y

msgbox z

msgbox "bye bye" 

Navigation: View menu > Debug Viewer > Use step into feature.

Environment Variables in QTP


 These are global variables; if you want to use some variables globally (From number of tests) declaring as global variables is better. If we declare as local variables in number of tests, modifications are difficult. 

Types of Environment variables:  

1. Built in variables: These are system defined variables, we can access from all tests but these are designed as read only.

2. User defined variables: Variables that we predefine in the active external environment variables file. We can create as many files as we want and we can change values of variables.

Usage of environment variables:  

Syntax: 

Variable = Environment(“environment variable name”)

Ex:  

X=Environment (“ActionName”)

Msgbox x 

Example Script:  

ProductDir =environment ("ProductDir")

app= "\samples\flight\app\flight4a.exe"

Systemutil.Run ProductDir & app

Dialog("Login").Activate

Dialog("Login").WinEdit("Agent Name:").Set "Monika"

Dialog("Login").WinEdit("Password:").SetSecure "4b3c86f2107ff565cc195ba6c24739091b656407"

Dialog("Login").WinButton("OK").Click

Creating user defined environment variables:  

Navigation:  

File > settings > Environment > select variable type as user defined > click add icon (+) > enter variable name & Value > click ok (like this we can create number of variables) > click export > browse path & enter file name, save with xml extension > click ok.

Associating environment variable file:  

Navigation: 

File > settings >Environment > select variable type as user defined > check “load variables and values from the external file” > browse path of the xml file > click apply & ok.

Or  

We can load environment file directly  

Environment.loadfromfile”path of the xml file” 

Usage of user defined Environment variables:  

Associate environment file to current test:

Variable = Environment (“Variable Name”) 

X=environment (“city”)

Msgbox x 

Modifying Environment files:  

Select XML file>open with notepad>modify the values>Save.

Actions in QTP

Action: Set of Statements for perfoming a Task(s)

We divide our test into actions to streamline the process of testing. 

Purpose of Actions:  

For understandability 

For reusing components 

Types of Actions:  

1) Non Re usable actions

2) Re usable actions

3) External actions 

Operations on Actions:  

• Creating Actions 

• Splitting Actions 

• Renaming Actions 

• Deleting Actions 

• Calling an Action 

• Copying an Action 

• Making an Action Reusable/Non Reusable 

Creating an Action:

Insert>call to new action>enter name of the action>click ok

Steps: 

1. Create required actions(ex login, insert,delte)

2. Prepare Scripts for those actions. 

Splitting an action:

Navigation: Place cursor in desired location>Edit menu>action>split action>Enter Action 1 name & action 2 name.

Steps:  

1. Generate total test in the default action

2. Split into meaningful actions. 

Note: At a time we can split one actions into 2 actions. 

Renaming actions:

Select desired action in action drop down box> edit menu>action>rename action>modify the name>click ok.

Deleting Actions:

Select desired action in action drop down box>edit menu>action>delete action>confirm deletion.

Calling an action:

Insert>call to existing action>browse path of the test>select desired action>click ok. 

Note: U can’t edit  

Copying an action:

Insert>call to copy of action>browse path of the test>select desired action>click ok. 

Note: we can edit this action. 

Making an action reusable:

Select Non Reusable action >edit >action>action properties>check reusable action check box >click ok.