Saturday, September 27, 2008

QTP Checkpoint Return Value Example

QTP Checkpoint Return Value


We will use the Standard Checkpoint which we did in tutorial 4.

Open that test that contains the standard Checkpoint.
In the expert view of the test you will see only one line i.e.

Window("Flight Reservation").WinButton("FLIGHT").Check CheckPoint("FLIGHT")

Now we will make some changes in this one line so that it can return some value.

NOTE: Checkpoint always returns a value, it depends on us whether we capture it or not.

Lets now capture it.
Declare a variable and catch the return value in that variable:

Dim return
return = Window("Flight Reservation").WinButton("FLIGHT").Check CheckPoint("FLIGHT")
msgbox (return)

One thing more we need to do here is that we have to enclose Checkpoint ("FLIGHT") in brackets. So the final version looks like this:

Dim return
return = Window("Flight Reservation").WinButton("FLIGHT").Check (CheckPoint("FLIGHT"))

msgbox (return)

Now run the test and see the msgbox appearing with the return value.

QTP Table Checkpoint Example

QTP Table Checkpoint


In this tutorial we will look at a table Checkpoint just to get familiar with it.

Open a blank test and also open a website "http://www.editorial.co.in/software/software-testing-life-cycle.php" in offline mode.

This website has a table at the bottom of the page.

Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click on ok.

Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12).

The mouse pointer will become hand and QTP will be minimized.

Click somewhere inside the table.

"Object Selection - Checkpoint properties" window opens.

Select "WebTable: Software Testing Life Cycle" which has a table icon on its left, where "Software Testing Life Cycle" is the name of the table.

Click ok.

'Table Checkpoint properties' window opens. It will show all the rows and columns of the selected table. This time we will not do any extra setting. Just change the Checkpoint timeout at the bottom of this window to 0 seconds and click ok .

Click stop in order to stop recording.

Run the test and analyze the results in the result window, mainly the checkpoint results to see how QTP verifies the result. We will manipulate test results in later tutorials.

QTP Text Checkpoint Example

QTP Text Checkpoint


Now we will look at the Text Checkpoint:

Open a blank test and a web page in offline mode like this below:

Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click on ok.

Go to Insert (menu)->Checkpoint->Text Checkpoint.The mouse pointer will become hand and QTP will be minimized.Click on the first paragraph (which starts with-The page you are looking..) of that web page.

"Text Checkpoint Properties" window opens up. It will show the text to be checked in "Checkpoint Summary" area in red color and also show in blue color the text which is displayed before and after the selected text.
Click on Configure -here you can change your selected text, change before and after text and so on, but for now just click ok. At the bottom of the "Text Checkpoint Properties" window change 'Checkpoint timeout' to 0 seconds. Again Click ok to come out of "Text Checkpoint Properties" window.
Click on stop in order to stop recording.
Run the test and when it is passed just go to the results window and on the left hand side just expand every option and click on last option Checkpoint "Cannot find server". On the right hand side it will show you the details. Try to understand those.

QTP Image Checkpoint

QTP Tutorials 8 - Image Checkpoint


We will look at the Image checkpoint.

Open a blank test.

On your system under My Documents, there will be a folder named My Pictures, under this you will will find a folder- Sample Pictures( containing 4 pictures - Blue Hills, Sunset, Winter, Water lilies)

We will run this test with one of the image there- Sunset.

Go to My Documents->My Pictures-> Sample Pictures and right click on image
named 'Sunset' and open it with internet explorer.

Now only a new blank test and internet explorer with this image should be open.

Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click on Ok.

Go to Insert (menu)->Checkpoint->Standard Checkpoint(or press F12).The mouse pointer will become hand and QTP will be minimized.

Click on the image which is opened in the explorer.

It will open 'Object Selection Checkpoint Properties' window with Image: Sunset highlighted. Click Ok.

It will Open 'Image Checkpoint Properties' Window. In this window just uncheck all the property values like href, html tag etc and only check last property which is src.

Rest every thing will be default. Click OK.

Click stop to stop recording the test.

In the expert view it will just add one line Browser("file:///C:/Documents%20and%20S").Page("file:///C:/Documents%20and%20S").Image("Sunset").Check CheckPoint("Sunset")

If you run it with that image open in internet explorer it will pass. This test is not intelligent enough. It is just checking that the image in the explorer is in the same location in which it was when the test was recorded and its name is Sunset. If you change the name of some other picture in that folder to Sunset and run the test with that it will also pass.

In this way you can test for some or all the properties of the image which it showed in the 'Image Checkpoint Properties' Window.

QTP Bitmap Checkpoint Example

QTP Bitmap Checkpoint


Now we will look at the bitmap checkpoint which is different from the image checkpoint.

Make sure that QTP and the Flight application are open.

STYLE A

Open a blank test.

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 Ok.

Go to Insert (menu)->Checkpoint->Bitmap Checkpoint

Click on the "Fly To" combo box.
"Object Selection- Bitmap Checkpoint Properties" window opens up. I will have "WinComboBox:Fly To" highlighted. Click ok
It will open "Bitmap Checkpoint Properties" window.

Change the "Checkpoint timeout" at the bottom of the window to 0 seconds, so that we will have no wait time while running the test.
Click ok.
Click stop to stop recording the test.
STYLE B

Above, after 3rd point, instead of clicking on the "Fly To" combo box, click somewhere in the empty space above the "Fly From" Combo box but below the line, i.e. in the "Flight Schedule" area.

"Object Selection- Bitmap Checkpoint Properties" window opens up. It will have "WinObject:Flight Schedule" highlighted. Click ok

It will open "Bitmap Checkpoint Properties" winodow. This time it will have "Flight schedule" area instead of just the "Fly To" combo box.

Now click on the "Select Area..." button. Mouse pointer will change so that you can select any area by dragging. Just select "Fly From" combo box by dragging.

Change the "Checkpoint timeout" at the bottom of the window to 0 seconds. so that we will have no wait time while running the test.

Click ok.

Click stop to stop recording the test.

Now you can run the test it will pass. To see how it stores the results, just fail the test. If you have recorded in the style A then just select any value in the "Fly To" combo box and then run the test. In the result window on the left hand side when you click on Checkpoint "Fly To:", it will show you the expected bitmap and actual bitmap on the right hand side. (note: it will show that only in case of Failed result)

QTP - Database Checkpoint Example

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)

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

A Database Query Wizard opens.
Select ' Specify SQL statement manually' from the Query definition area. Click Next.
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
Click on New Button.
'Create New Data Source' window opens.
Select 'User Data Source' from Select a type of data source. Click Next.
It will show all the data source drives it could find.
Select Oracle (on my machine it was 'Oracle in OraHome9'). Click Next. Click Finish.
It will open 'Oracle ODBC Driver Configuration' window.
Enter 'Data Source name' ( I entered "oracle")
Enter 'description' (I entered "SQL")
Select 'TNS Service Name' ( I selected 'DB02', my oracle database name) from combo box.
Enter userid (I used SCOTT).
Click 'Test Connection' Button.It will ask for a Password. Enter your password for Oracle.
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.

Open a blank test.

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.
Go to Insert (menu)->Checkpoint->Database Checkpoint
A 'Database Query Wizard' opens.

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

Enter password. Click ok
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.

It will open 'Database Checkpoint Properties' window with the result of the query. Click Ok.
Click Stop in order to stop the Recording.

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.

QTP Page Checkpoint

Page checkpoint:It is for web applications only.Common things to check with this are load time, broken links etc.
Open a blank test.
Make sure thathttp://www.google.co.in/ is open.(Now only QTP with blank test and www.google.co.in should be open.)
Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Web" tab and choose first option "Record and run test on any open browser." and click ok.
Go to Insert (menu)->Checkpoint->Standard Checkpoint (or press F12).
The mouse pointer will become hand and QTP will be minimized.
Click anywhere on the white space on the Google.co.in page.
It will Open "Object Selection - Checkpoint Properties" window. Click on 'Page : Google' option which has a page icon on left of it with right corner of the page slightly folded.
Click ok.
A 'Page Checkpoint Properties' window opens up. Let all the options be default. Click ok.
Click on Stop in order to stop the Recording.
In the Expert view it will add just one line:
Browser("Google").Page("Google").Check CheckPoint("Google")
We will explore this line later on.
I ran this test by opening www.google.co.in in offline mode (not on internet). It recorded the following properties:
Property Name Property Value

load time "0"

number of images "2"

number of links "20"

Here it shows the load time as 0 because I did not open Google at the time of running the test, it was already open.
When you run it, in the results window, on left hand side, it will show (when every option is expanded):
Test Checkpoint-page Summary (where Checkpoint-page is the name with which I saved the test
Run-Time Data Table
Checkpoint-page Iteration 1 (Row 1)
Action1 Summary
Google (This will be the browser)
Google (This will be the Page)
Checkpoint "Google"
If you run this test on www.google.com it may fail.