Tuesday 25 September 2012

Inserting Checkpoints



Inserting Checkpoints

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:
a)     If item is available but not according to W3C rules then fail.
b)     If an item is available, according to W3C rules then Pass.
c)     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.

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

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

Under Standing checkpoint

Checkpoint Type
Description
Example of Use
Standard Checkpoint
Checks values of an object's properties.
Check that a radio button is selected.
Image Checkpoint
Checks the property values of an image.
Check that the image source file is correct.
Table Checkpoint
Checks information in a table.
Check that the value in a table cell is correct.
Page Checkpoint
Checks the characteristics of a Web page.
Check how long a Web page takes to load or if a Web page contains broken links.
Text Checkpoint
Checks that a text string is displayed in the appropriate place in a Web page or application.
Check whether the expected text string is displayed in the expected location in a test object.
Text Area Checkpoint
Checks that a text string is displayed within a defined area in a Windows-based application.
Check that an area of a dialog box includes text that was entered in another part of the application.
Bitmap Checkpoint
Checks an area of a Web page or application after capturing it as a bitmap.
Check that a Web page (or any portion of it) is displayed as expected.
Database Checkpoint
Checks the contents of databases accessed by an application or Web site.
Check that the value in a database query is correct.
Accessibility Checkpoint
Identifies areas of a Web site to check for Section 508 compliancy.
Check if the images on a Web page include ALT properties, required by the W3C Web Content Accessibility Guidelines.
XML Checkpoint
Checks the data content of XML documents.
Check the content of an element to make sure that its tags, attributes, and values have not changed.
Note: XML file checkpoints are used to check a specified XML file; XML application checkpoints are used to check an XML document within a Web page.

PROGRAMS :-
           
Bit Map check point:
invokeapplication("C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight3a.exe")
Dialog("Login").WinEdit("Agent Name:").Set "aaaa"
Dialog("Login").WinEdit("Password:").SetSecure "mercury"
Dialog("Login").WinButton("OK").Check CheckPoint("OK_2")
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close

Page check points :


systemutil.Run "iexplore","http://balaprasadreddy/login.jsp"
Browser("Browser").Page("actiTIME - Login").Check CheckPoint("actiTIME - Login_3")
Browser("Browser").Page("actiTIME - Login").WebEdit("username").Set "admin"
Browser("Browser").Page("actiTIME - Login").WebEdit("pwd").SetSecure "manager"
Browser("Browser").Page("actiTIME - Login").WebButton("Login now").Click
Browser("Browser").Page("actiTIME - Login_2").Check CheckPoint("actiTIME - Login")
Browser("Browser").Page("actiTIME - Login_2").Check CheckPoint("actiTIME - Login_2")
Browser("Browser").Page("actiTIME - Open Tasks").Link("Completed Tasks").Click

Browser("Browser").Page("actiTIME - Active Projects").WebButton("Add New Customer").WaitProperty "disabled", false, 10000
Browser("Browser").Page("actiTIME - Completed Tasks").Link("Projects & Customers").Click
Browser("Browser").Page("actiTIME - Active Projects").WebButton("Add New Customer").Click
Browser("Browser").Page("actiTIME - Active Projects").WebButton("Add New Customer").Click
Browser("Browser").Page("actiTIME - Active Projects").Check CheckPoint("actiTIME - Active Projects & Customers")

Standard check point

systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight3a.exe"
Dialog("Login").WinEdit("Agent Name:").Set "aaaa"
Dialog("Login").WinEdit("Password:").SetSecure "mercury"
Dialog("Login").WinButton("OK").Check CheckPoint("OK_3")
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close

Text Area :
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "dddd"
Dialog("Login").WinEdit("Password:").SetSecure "mercury"
Dialog("Login").WinButton("Cancel").Check CheckPoint("Cancel")
Dialog("Login").WinButton("Help").Check CheckPoint("Help")
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close


Sunday 23 September 2012

QTP Methods / Operations




 QTP Methods / Operations
1) Activate Method

It activates dialog boxes/Windows

Syntax: Object hierarchy. Activate
 Ex:
Dialog(“Login”).Activate
Window(“Flight Reservation”).Activate

2) Click Method
It clicks on an object (Buttons)
Syntax: Object hierarchy. Click
Ex:
Dialog(“Login”).Winbutton(“ok”).click

3) Close Method
It closes the window,Dialog box, Browser window etc.
Syntax: Object hierarchy. Close
Ex:
Window(“Flight Reservation”).Close
Browser(“Browser”).Close

4) Dblclick 
It Double clicks the object.

5) Set Method
It can be used in three ways.
a. For setting the value of an edit box
Syntax: Object Hierarchy. SET “Value”
Ex: Dialog (“Login”).WinEdit(“Agent Name”).Set “asdf”

b. Selecting a Radio Button
Syntax: Object Hierarchy. Set
Ex: Window("Flight Reservation").WinRadioButton("Business").Set

c. Selecting/Deselecting check boxes
Syntax:object Hierarchy.Set “ON/off”
Ex: Window ("Flight Reservation"). Dialog("Open Order").WinCheckBox("Order No.").Set "ON"

6) Select Method:
It is used for selecting an item from a combo box or list box.
Syntax: Object hierarchy.select “item”
Ex:
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12572

7) GetVisibletext: It returns Text from the specified area.
Syntax: Variable =object hierarchy.getvisibletext
Ex:
x=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText
msgbox x

8) GetRoproperty:
It returns current object property value. It can be used for getting any object’s, any property value.
Syntax: Variable = object hierarchy.getroproperty (“property name”)
Ex: x=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty ("width")
msgbox x

9) Navigate Method:
It opens a specified URL in the Browser.
Syntax: object hierarchy.navigate “URL”
Ex: Browser("Yahoo!").Navigate http://www.google.co.in/

10) Getitemscount: It returns number of items in a combobox.
Syntax: Variable=object hierarchy.getitemscount
Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
msgbox x

11) Getcontent: It returns all items from a combobox.
Syntax: variable=object hierarchy.GetContent
Ex: x=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
msgbox x

12) Exist property: It checks whether the object is available or not.
Syntax: Object hierarchy.exist(time in seconds)
Ex: Window("Flight Reservation").Exist(5)
QTP Data Table Methods

(1) Add Sheet:
We can use this method to “add” one new sheet to the run time data table.
Syntax: DataTable.AddSheet "sheet name"
Ex: DataTable.AddSheet "gcreddy"

(2) Delete Sheet:

We can use this method to “delete” one specified sheet from the Run Time Data table.


Syntax: datatable.DeleteSheet (Sheet_ID)
Ex: datatable.DeleteSheet (3)


(3) GetSheetCount

We can use this method to count number of sheets in the run time data table.


Syntax:
datatable.GetSheetCount
msgbox datatable.GetSheetCount

(4) GetRowCount


We can use this method to count number of rows in the 1st sheet
(longest column) of the Run time data table.


Syntax: datatable.GetRowCount


Ex: msgbox datatable.GetRowCount

(5) GetSheet


We can use this method to return a specified sheet from the Run Time data table.


Syntax: datatable.GetSheet(SheetID)


Ex: msgbox datatable. GetSheet(1).GetRowCount


(6) Value

We can use this method to set or get value of cell in the specified parameter and the current row of the Rum time data table.


To set data


Syntax: datatable.Value(Parameter_Name, Sheet_Name) = Value / variable Or

datatable(Parameter_Name, Sheet_Name) = Value / variable


To get data

Syntax: Variable = datatable.Value(Parameter_Name, Sheet_Name) Or

Variable = datatable(Parameter_Name, Sheet_Name)


Ex:

Option explicit Dim a, b, c


a=datatable.Value (1,1) b=datatable.Value (2,1) c=cint(a)+cint(b) datatable.Value (3,1) = c

Note: Default property of Datatable is value

(7) SetCurrentRow


We can use this method to take a specified row as current row in the Run Time Datatable (By default it is 1st Row of 1st Sheet)

Syntax: datatable.SetCurrentRow(Row_Number)

g="gcreddy"

datatable.SetCurrentRow (3) datatable.Value (1,1) = g


(8) SetNextRow


We can use this method to take the row after the current Row as New Current Row in the Run time data table.


Syntax: datatable.SetNextRow

Ex: g="gcreddy"

datatable.SetCurrentRow (3) datatable.SetNextRow datatable.Value (1,1) = g


(9) SetPrevRow

We can use this method to take the row before the current Row as New Current Row in the Run time data table.


Syntax: datatable.SetPrevRow


Ex: g="gcreddy"


datatable.SetCurrentRow (3) datatable.SetPrevRow datatable.Value (1,1) = s


(10) Import

We can use this method to import Microsoft Excel File to the Runtime Data Table (Including all sheets)


Syntax: datatable.Import “Path of File”

Ex: datatable.Import “F:\Inputdata.xls”

11) ImportSheet

We can use this method to import a specified sheet of Microsoft Excel Sheet to the Runtime Data table.


Syntax: datatable.ImportSheet “Path of File”, “Source Sheet”, “Destination Sheet”

Ex: datatable.ImportSheet “E:\gcreddy.xls”,3,1

(12) Export


We can use this method to export a copy of Run Time Data table to another location (Including all sheets)


Syntax: datatable.Export “Path of File”


Ex: datatable.Export “F:\gcreddy.xls”


13) ExportSheet


We can use this method to export a copy specified sheet of Run Time Data table to the existing or new Excel File.

Syntax: datatable.ExportSheet “Path of File”, “Sheet Name / Source Sheet”


Ex: datatable.ExportSheet “F:\anji.xls”, 2
Data Driven Testing for Login Operation using Data Table methods


Datatable.AddSheet "Login"
Datatable.ImportSheet "C:\Documents and Settings\gcr\Desktop\gcreddy.xls",1,3
Rows_count=Datatable.GetSheet(3).GetRowCount

For i= 1 to Rows_count
    Datatable.SetCurrentRow(i)
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Datatable("Agent",3)
Dialog("Login").WinEdit("Password:").Set Datatable("Pwd",3)
Dialog("Login").WinButton("OK").Click

If window("Flight Reservation").exist(10) Then
    Login="Login Operation Successful"
    Datatable("Result",3)=Login
    Reporter.ReportEvent micPass,"res","Passed"
    else
Reporter.ReportEvent micFail,"res","Failed"
Login="Login Operation Failed"
Datatable("Result",3)=Login

Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Cancel").Click
End If

If Window("Flight Reservation").Exist(3)Then
    Window("Flight Reservation").Close
    End if
Next
Synchronization
It is a process of matching the speeds of both QTP and AUT in order to get proper execution and results.


Where Synchronization is required:

During test execution QTP gives instructions one by one with same speed, but AUT takes less time for some operations execution and more time for some operations execution, that time we may not get proper execution and results. In order to get proper results in between QTP & AUT synchronization is required.

There are several methods available in QTP for synchronization.

1. Inserting Wait statements.
2. Inserting Synchronization points.
3. Increasing Tool default synchronization time.
4. Sync Method (Only for WEB)
5. Exist Property

Inserting Wait Statements:
We can insert wait statements in our test in order to make QTP to wait until AUT completes current operation.
Syntax: Wait(time in seconds)

Note: If we insert wait statements QTP waits up to maximum time even though operation is completed.

Inserting Synchronization points:

Place cursor in desired location>keep tool under recording mode>Insert menu>Synchronization point >show the object >click ok>select property name & Value(True)>enter time in Milli seconds>click ok>Stop recording.

Note: if we insert Synchronization points, it does not wait up to maximum time, after completion of the current operations, it goes to next step immediately.

Syntax: object hierarchy.waitproperty “property name”,value,time in milli seconds.

Increasing Tool default synchronization time:

Navigation: File>settings>run tab>increase object synchronization time out>apply>ok
Note: If we increase QTP tool default time that can be applied for all statements in the test, but QTP does not wait up to maximum time unnecessarily, After completion of one statement execution it goes to next statement immediately.

Sync Method: (only for WEB)
Waits for the browser to complete current navigation.

Syntax: Object Hirearchy.Sync
Ex: Browser("Yahoo! Toolbar").Page("Yahoo! Toolbar").Sync

Selecting an appropriate Method:

1. Suppose in our test one or more statements only are taking more time for execution then selecting “Inserting synchronization method” is better.

2. Suppose in our test more statements are taking more time for execution then selecting “increasing tool time out” .

3. Above two are local features but wait statement is Vbscript feature, even though some drawbacks are there in using wait statement, it is better to use wait statement in functions.

Advantages of Wait Statement:
1)  It is a VBScript statement, we can use this globally

2) It is recommended, whenever we want to observe the Test Execution process
3) No object reference required to insert wait statements

4) It is useful to make QTP capture values and screen shots during test execution