Sunday, May 10, 2009

QTP Parameterizing Checkpoint Example

A checkpoint that uses different expected results for each iteration.

A small example:

You have certain user names (say 3 in our case) in the data table. You want that only users which are in the data table should be able to login and other could not.

1.
Make sure that http://mail.yahoo.com is open and create a standard checkpoint for the Yahoo! ID field.
  • While both yahoo mail login and QTP are open, click Record.
  • Go to Insert->Checkpoint->Standard Checkpoint
  • QTP will be minimized and mouse pointer will take the shape of a hand.
  • Click on the Yahoo! ID text field.
  • Object Selection – Checkpoint Properties window opens, click on Ok.
  • Checkpoint Properties window opens, click on Ok.
2.
The following line will get recorded in QTP

Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebEdit("login").Check CheckPoint("login")

3.
Stop recording.

4.
Make sure you are in the Expert View. Right click on CheckPoint and select CheckPoint Properties.

5.
Checkpoint Properties window opens. Highlight the value property and Select Parameter radio button.

6.
Click on the Edit icon on the right side of the Parameter radio button.
Parameter Options window opens. Just select the Current action sheet (local) radio button.

7.
Click Ok. Again click Ok to come out of Checkpoint Properties window.

8.
Check the local data sheet. The first column name must be login_value.

9.
Add any three names in the first three rows and modify the code as follows:



So the final code looks like this:



Now if you run the test it will ask you for each user name you want to enter and compare it with the ones already there in the data table as we have created a check point on it.


Now to see if our checkpoint really works use checkpoint return value to check. For every value you enter, if it is in the data table, it will return true, otherwise false.



Also See:
Parameterize a checkpoint for a Flight Application Login Window.