Sunday, August 5, 2007

QTP Tutorials 6 - Database Checkpoint

Now we will try out Database checkpoint: using Oracle 9i

First of all you have to connect oracle 9i to QTP 9.(before doing any recording)

  1. For this go to Insert -> Checkpoint -> Database Checkpoint.

  2. A Database Query Wizard opens.
    Select ' Specify SQL statement manually' from the Query definition area. Click Next.
  3. Here click on 'Create' button which is on the right of "Connection String:" It will open 'Select Data Source' window. Click on 'Machine Data Source' Tab
  4. Click on New Button.
  5. 'Create New Data Source' window opens.
  6. Select 'User Data Source' from Select a type of data source. Click Next.
  7. It will show all the data source drives it could find.
  8. Select Oracle (on my machine it was 'Oracle in OraHome9'). Click Next. Click Finish.
  9. It will open 'Oracle ODBC Driver Configuration' window.
  10. Enter 'Data Source name' ( I entered "oracle")
  11. Enter 'description' (I entered "SQL")
  12. Select 'TNS Service Name' ( I selected 'DB02', my oracle database name) from combo box.
  13. Enter userid (I used SCOTT).
  14. Click 'Test Connection' Button.It will ask for a Password. Enter your password for Oracle.
  15. If successful it will show 'Testing Connection' window with 'Connection Successful' written on it.

This completes our task of Connecting QTP with Oracle.


Now we will record a test.

  1. Open a blank test.

  2. Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Windows Applications" tab and choose first option "Record and run test on any open Windows based application." and click on ok.
  3. Go to Insert (menu)->Checkpoint->Database Checkpoint
  4. A 'Database Query Wizard' opens.

  5. Select ' Specify SQL statement manually' from the Query definition area. Click Next. Click Create.
  6. Go to 'Machine Data Source' Tab
  7. Select Oracle from data source name. Click Ok. It will open 'Oracle ODBC Driver Connect'

  8. Enter password. Click ok
  9. It will come to Database Query Wizard window with 'Connection String' field filled with: "DSN=oracle;UID=SCOTT;PWD=TIGER;DBQ=DB02;DBA
    =W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;
    LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MTS=F;
    MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;"
    In the SQL Statement area type "select * from emp;". Click Finish.
  10. It will open 'Database Checkpoint Properties' window with the result of the query. Click Ok.
  11. Click Stop in order to stop the Recording.

  12. In the Expert View, it just adds one line "DbTable("DbTable").Check CheckPoint "DbTable")"

This is the simplest database checkpoint example.

Lets run it.

Click on Run. ( we don't need to open any other window or application to run this as our Oracle is running at the back end as a service - default way in which it was installed- nothing special.)

When it is passed it will show following in the Result window:

Test Checkpoint-database Summary (where Checkpoint-database is the name with which I saved the test)

Run-Time Data Table
Checkpoint-database Iteration 1 (Row 1)
Action1 Summary
DbTable
Checkpoint "DbTable"

( when you click on this, in details it will show checked 112 cells (in your case number of cells may differ). It means if you go to the oracle and add or delete any row and run this test again it will fail.)

Just try to think how QTP is comparing the expected results with the actual one, with the count of cells.




Also See:

Checkpoints in QTP
Example of QTP Standard Checkpoint
Example of QTP Existing Checkpoint
Example of QTP Page Checkpoint
Example of QTP Bitmap Checkpoint
Example of QTP Image Checkpoint
Example of QTP Text Checkpoint
Example of QTP Table Checkpoint
Checkpoint Return Values
Difference between Text & Text Area Checkpoint