Check Points
Check points are used to validate Object Properties, Comparing Text, Comparing Images, Validate Database…etc.
[OR] Check point is a verification point, it takes expected result from the user and compares with actual results
during execution and provides test results.
Types of Check Points: - There are 9 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. Image checkpoint
7. Table checkpoint
8. XML Check point (from Application)
9. XML Check point (from Resource)
1. Standard Checkpoint: It is used to validate object properties
Navigation: -Open AUT Click Record in Qtp Insert Menu Check Point Select Standard Checkpoint
With help of handler Select Required Object Click on OK buttonSelect Expected properties and
Values Click on OK Button.
Syntax: -
Ex: - Dialog (“Login”) .WinButton (“ok”). Check Checkpoint (“ok”)
Draw Backs of Check Checkpoint: -
All Checkpoint syntax is same and hence unable to find what kind of Checkpoint it is.
Copied checkpoint statement does not run in another script (Action)
And hence above are the reasons mostly we are not using any checkpoints, we convert checkpoints
scenarios in to VBScript
Converting check points to VBScript:
If Window (“Flight Reservation”).WinButton (“insert Order”).GetROProperty (“enabled”)=”true” Then
Window (“Flight Reservation”).WinButton (“insert Order”).Click
Else
MsgBox “Insert Order is disabled”
2. Text Checkpoint: -It is used to validate given text in given object
Navigation: - Open AUTClick Record in QtpInsert MenuCheck PointSelect Text Checkpoint With
help of handler Select Required ObjetClick on OK buttonClick on Configuration ButtonSelect required
textClick on OK Button Stop Recording
Ex: -Window (“notepad”).WinEditor (“Edit”). Check Checkpoint (“Edit”)
Converting check points to VBScript:
In Notepad: - My name is Sreekar there is no prerequisite for learning QTP please come here and learn
QTP validate QTP is exist in notepad
sText = Window (“notepad”).WinEditor (“Edit”).GetROProperty (“Text”)
If InStr (sText, “qtp”) > 0 Then
MsgBox “Text is found”
Else
MsgBox “Text is Not Found”
3. Text Area Checkpoint: - It is used to validate given text is exist in between given text
Navigation: - Open AUTClick Record in QtpInsert MenuCheck PointSelect Text Area
CheckpointSelect Required Textclick on OK ButtonSelect Checked Text, Check After Text, Checked Before TextClick on OK ButtonStop Recording
Ex: -Window (“notepad”).WinEditor (“Edit”). Check Checkpoint (“Edit”)
In Notepad: - My name is Sreekar there is no prerequisite for learning QTP please come here and learn QTP
validate QTP is exist in notepad
H.W:- Validate Sreekar is existing in Between name and QTP
4. Bitmap Checkpoint: -It is used to compare two images
Navigation: - Open AUTClick Record in QtpInsert MenuCheck PointSelect Bit Map
CheckpointSelect the Expected Imageclick on OK Button Stop RecordingMinimize or Close expected
ImageOpen actual image[which need to Test] Run ScriptAnalyze the Result
Scripts related to Standard Checkpoint Check Points
Scripts related to Standard Checkpoint:
Script No3: - Write a script to validate Calculator Functionalities
Script No4: - Write a script for Object Existence [Validation of Vehicle Insurance]
Scripts related to Standard Checkpoint Check Points
How to get the Menu Options if we are not able to find with Obj Spy?
Script: - ********** Write a script to Select MENU Options
Method 1: - In Menu Options we cannot identify the objects with Object Spy through Recording we are
going to generate the script
Window ("Flight Reservation").Activate
Window ("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window ("Flight Reservation").WinMenu("Menu").Select "Help;About..."
Method 2: - Without Recording we get the Menu items by using short cut keys
Window ("Flight Reservation").Activate
Window ("Flight Reservation").Type micAltDwn + "h" + micAltUP + "a"
QTP - Chapter V
Scripts related to Standard Checkpoint Check Points
Script No12: - Write a Script to find given value is exist in DROP DOWN
Example: -kesinenitravels.com validate “HYDERABAD” is exist in from drop down
Method 1:-
Option Explicit
Dim sExpItem,iFlag,iItemCnt,index,sItemName,obj
sExpItem = "KURNOOL"
iFlag = 0
Set obj = Browser("Kesineni").Page("Kesineni")
iItemCnt = obj.WebList("From").GetROProperty("items count")
For index = 1 To iItemCnt
sItemName = obj.WebList("From").GetItem(index)
If sItemName = sExpItem Then
Print "Item is Found"
iFlag = 1
Exit for ' If we did not declare this the loop will iterate after getting the result also
End If
Next
If iFlag = 0 Then
print "Item Not Found" 'if we give it within for loop it iterates, so we took Flag for this
End If
Limitation: - Above Logic executes for all items if the items are at end or not found
Method 2:-
On Error Resume Next ‘It skips the Errors if any occurs in script running time
Set obj = Browser("Kesineni").Page("Kesineni")
obj.WebList("From").Select sExpItem
If Err.Number = 0 Then ‘Err.Number will give the script run time ERROR NUMBERS it is VB Utill
MsgBox "Item is found"
Else
MsgBox "Item Not Found"
End If
Limitation: -If item is not found then result window displays with RUNTIME ERROR which we won’t accept
Method 3:-
Question: - Write a script for dropdown
On Error Resume Next ‘It skips the Errors if any occurs in script running time
Set obj = Browser("Kesineni").Page("Kesineni")
sItemName = obj.WebList("From").GetROProperty("all items")
If InStr(sItemName, sExpItem) > 0 Then
MsgBox "Item is Found"
Else
MsgBox "Item Not Found"
End If
Question: - How do you find Combobox or ListBox items?
In Windows based application we have “GetItemCount”
In Web based application we have “GetROProperty (“item count”)”
Note:-****
1. Err.Number: - To identify runtime error number
2. On Error Resume Next: - When we get any error in script execution it skips that line goes to next
Scripts related to Standard Checkpoint Check Points
Script No13: - Write a script for Rail Reservation
Script No13: - Write a script for Rail Reservation
Set obj = Browser("Reservation").Pabe("Reservation")
obj.WebEdit("Name").Set "Sreekar"
obj.WebEdit("Age").Set "32"
obj.WebList("Gender").Select "Male"
obj.WebList("Name").Select "Hyderabad"
obj.WebList("Name").Select "Kurnool"
'Validate default Class
If obj.WebRadioGroup("Class").GetROProperty("value")
= "AC" Then
MsgBox "Default Class is AC"
Else
MsgBox "Default Class is Not AC"
End If
‘Validate Class Price
obj.WebRadioGroup("Class").Select "AC"
iTcktPrice = obj.WebEdit ("Ticket Price").GetROProperty("text")
iTcktPrice = Mid(iTcktPrice,4,Len(iTcktPrice)-5) 'Rs:1000/-
If iTcktPrice = "1000" Then
MsgBox "AC Price is 1000/-"
Else
MsgBox "AC Price Not 1000/-"
End If
obj.WebRadioGroup("Class").Select "Sleeper"
iTcktPrice = obj.WebEdit ("Ticket Price").GetROProperty("text")
iTcktPrice = Mid(iTcktPrice,4,Len(iTcktPrice)-5) 'Rs:1000/-
If iTcktPrice = "1000" Then
MsgBox "Sleeper Price is 500/-"
Else
MsgBox "Sleeper Price Not 500/-"
End If
'Validate No of Tickets
iTickets = InputBox("Enter number of Tickets")
obj.WebEdit("Tickets").Set iTickets
obj.WeButton("Submit").Click
iTotalPrice = obj.WebEdit("Total Price").GetROProperty("text")
iTotalPrice = Mid(iTotalPrice,4,Len(iTotalPrice)-5)
If iTotalPrice = iTickets * iTicketPrice Then
MsgBox "Total Price Functionality Validation is Pass"
Else
MsgBox "Total Price Functionality Validation is Fail"
End If
iTcktNo = obj.WebEdit("TicketNo").GetProperty("text")
If NOT IsEmpty (iTcktNo) Then
MsgBox "Ticket Noumber Validation is Pass"
Else
MsgBox "Ticket Noumber Validation is Fail"
End If
Scripts Related to Text Checkpoint
Ex: - Notepad: - my name is sreekar there is no prerequisite for learning QTP please come here and learn QTP
Script No5: -Write a script to Validate Text Existence
Ex: - Notepad:
Validate sreekar text existence:-
Option Explicit
Dim sActTxt, sExpTxt
sExpTxt = "sreekar"
sActTxt =
Window("Notepad").WinEditor("Edit").GetROProperty
("text")
If InStr(sActTxt, sExpTxt) > 0Then
MsgBox "Text is Found"
Else
MsgBox "Text is Not Found"
End If
Script No5: -Write a script to Validate Text Existence
Ex: - Notepad:
Validate sreekar text existence:-
Option Explicit
Dim sActTxt, sExpTxt
sExpTxt = "sreekar"
sActTxt =
Window("Notepad").WinEditor("Edit").GetROProperty
("text")
If InStr(sActTxt, sExpTxt) > 0Then
MsgBox "Text is Found"
Else
MsgBox "Text is Not Found"
End If
Script No6: -Write a script to find the string number of
occurrences
Ex: - Notepad:
Find sreekar text number of occurrence:-
Option Explicit
Dim sActTxt, sExpTxt
sExpTxt = "sreekar"
sActTxt =
Window("Notepad").WinEditor("Edit").GetROProperty
("text")
MsgBox (Len(sActTxt)-
Len(Replace(sActTxt,sExpTxt,"")))/ Len(sExpTxt)
occurrences
Ex: - Notepad:
Find sreekar text number of occurrence:-
Option Explicit
Dim sActTxt, sExpTxt
sExpTxt = "sreekar"
sActTxt =
Window("Notepad").WinEditor("Edit").GetROProperty
("text")
MsgBox (Len(sActTxt)-
Len(Replace(sActTxt,sExpTxt,"")))/ Len(sExpTxt)
Script No7: - Write a script to find the ovals
Ex: - Notepad: -
Option Explicit
Dim sActTxt, iACnt,iECnt,iICnt,iOCnt,iUCnt
sActTxt =
Window("Notepad").WinEditor("Edit").GetROProperty(
"text")
iACnt = Len(sActTxt)-Len(Replace(sActTxt,"a",""))
iECnt = Len(sActTxt)-Len(Replace(sActTxt,"e",""))
iICnt = Len(sActTxt)-Len(Replace(sActTxt,"i",""))
iOCnt = Len(sActTxt)-Len(Replace(sActTxt,"o",""))
iUCnt = Len(sActTxt)-Len(Replace(sActTxt,"u",""))
MsgBox iACnt+iECnt+iICnt+iOCnt+iUCnt
Ex: - Notepad: -
Option Explicit
Dim sActTxt, iACnt,iECnt,iICnt,iOCnt,iUCnt
sActTxt =
Window("Notepad").WinEditor("Edit").GetROProperty(
"text")
iACnt = Len(sActTxt)-Len(Replace(sActTxt,"a",""))
iECnt = Len(sActTxt)-Len(Replace(sActTxt,"e",""))
iICnt = Len(sActTxt)-Len(Replace(sActTxt,"i",""))
iOCnt = Len(sActTxt)-Len(Replace(sActTxt,"o",""))
iUCnt = Len(sActTxt)-Len(Replace(sActTxt,"u",""))
MsgBox iACnt+iECnt+iICnt+iOCnt+iUCnt
Script No8: - Write a script to find number of Alphabets
Ex: - Notepad: -
Option Explicit
Dim sActTxt,index,iCnt, iChrCnt
iChrCnt = 0
sActTxt = UCase(
Window("Notepad").WinEditor("Edit").GetROProperty(
"text"))
MsgBox Len(sActTxt)
For index = 65 To 90 'upper Case A - Z
iCnt = Len(sActTxt) - Len(Replace(sActTxt,
Chr(index),""))
iChrCnt=iChrCnt + iCnt
Next
MsgBox iChrCnt
Ex: - Notepad: -
Option Explicit
Dim sActTxt,index,iCnt, iChrCnt
iChrCnt = 0
sActTxt = UCase(
Window("Notepad").WinEditor("Edit").GetROProperty(
"text"))
MsgBox Len(sActTxt)
For index = 65 To 90 'upper Case A - Z
iCnt = Len(sActTxt) - Len(Replace(sActTxt,
Chr(index),""))
iChrCnt=iChrCnt + iCnt
Next
MsgBox iChrCnt
Script No9: - Write a script to find number of strings in a given text [&_ for Continue the line]
Option Explicit
Dim sActTxt,index,iCnt, iChrCnt
sActTxt = "my name is sreekar there is no prerequisite for learning QTP"&_
"Please come here and learn QTP"
iChrCnt = 0
sActTxt = Split (sActTxt, " ")
MsgBox UBound (sActTxt) + 1
Option Explicit
Dim sActTxt,index,iCnt, iChrCnt
sActTxt = "my name is sreekar there is no prerequisite for learning QTP"&_
"Please come here and learn QTP"
iChrCnt = 0
sActTxt = Split (sActTxt, " ")
MsgBox UBound (sActTxt) + 1
Scripts related to Text Area Checkpoint
Script No10: -Write a Script to find given text existence in between given two texts
Ex: - Notepad:Find sreekar in between name and QTP
Script No10: -Write a Script to find given text existence in between given two texts
Ex: - Notepad:Find sreekar in between name and QTP
Script No11: - Write a script to retrieve Driver letter, File Path and File Name from given Text
Option Explicit
Dim sActTxt,index,iCnt, iChrCnt
sActTxt = "D:\sreekar\batch40\test scripts\sample\sample.mts"
MsgBox "Driver Letter is: - " & Mid(sActTxt,1,1)
MsgBox "File Name is: - " & Mid(sActTxt,InStrRev(sActTxt,"\")+1)
MsgBox InStrRev(sActTxt,"\")
MsgBox "File Path is: -" & Mid(sActTxt,4, InStrRev(sActTxt,"\")-4)
[Here to find the file path we subtracted 4 {1st 3 {D :\} letters and last occurrence of “\”}]
CaptureBitMap: - It is used to take a screen for the given object
Syntax: -.CaptureBitMap “Path.bmp/png”
Syntax: -
Ex: -
Capture Login
Dialog("Login").CaptureBitMap "E:\01 My Scripts\login.bmp"
Capture Login
Dialog("Login").CaptureBitMap "E:\01 My Scripts\login.bmp"
Capture OK button in Login Dialog Dialog("Login").WinButton("OK").CaptureBitMap "E:\01 My Scripts\loginokbtn.bmp"
Note: - When we capture child object, QTP captures only child Object
Capture Desktop
Window ("text:= QuickTest.*").Minimize
Desktop.CaptureBitmap("E:\01 My Scripts\Desktop.bmp")
Window("text=QuickTest.*").Maximize [;- Descriptive Programming]
Script No14: - Write a script to Right Click on Notepad editor and select past by using down arrow key
Set obj = CreateObject ("WScript.Shell")
Window("Notepad").Activate
iXCord = Window("Notepad").WinEditor("Edit").GetROProperty("x")
iYCord = Window("Notepad").WinEditor("Edit").GetROProperty("y")
Window("Notepad").Activate
Window("Notepad").WinEditor("Edit").Click iXCord, iYCord,micRightBtn
obj.SendKeys "{DOWN}" ' These things we can write in Loop
Wait(1)
obj.SendKeys "{DOWN}"
Wait(1)
obj.SendKeys "{DOWN}"
Wait(1)
obj.SendKeys "{DOWN}"
obj.SendKeys"{ENTER}"
Window("Notepad").Activate
iXCord = Window("Notepad").WinEditor("Edit").GetROProperty("x")
iYCord = Window("Notepad").WinEditor("Edit").GetROProperty("y")
Window("Notepad").Activate
Window("Notepad").WinEditor("Edit").Click iXCord, iYCord,micRightBtn
obj.SendKeys "{DOWN}" ' These things we can write in Loop
Wait(1)
obj.SendKeys "{DOWN}"
Wait(1)
obj.SendKeys "{DOWN}"
Wait(1)
obj.SendKeys "{DOWN}"
obj.SendKeys"{ENTER}"
For index= 1 To 4
obj.SendKeys "{DOWN}"
wait(1)
Next
obj.SendKeys "{DOWN}"
wait(1)
Next
Script No15: - Write a script to open an existing notepad right click on it, select “Select All “option by pressing/
Sending UP arrow key (in windows 7 it differs) one time, Right Click on Notepad, select copy option by sending
Down arrow key for 3 (in windows 7 it differs) times, close the notepad, open a new notepad, Right Click on it
select past by sending UP arrow key for 3(in windows 7 it differs) times.
SystemUtil.Run "E:\01 My Scripts\1.txt"
Set obj = CreateObject("WScript.Shell")
'Window("Notepad").Activate
iXCord = Window("Notepad").WinEditor("Edit").GetROProperty("x")
iYCord = Window("Notepad").WinEditor("Edit").GetROProperty("y")
'Window("Notepad").Activate
Window("Notepad").WinEditor("Edit").Click iXCord, iYCord,micRightBtn
For index = 1 To 6
obj.SendKeys"{UP}"
'Wait(1)
Next
obj.SendKeys"{ENTER}"
'Wait(1)
Window("Notepad").WinEditor("Edit").Click iXCord, iYCord,micRightBtn
For index1 = 1 To 3
obj.SendKeys"{DOWN}"
'Wait(1)
Next
obj.SendKeys"{ENTER}"
Window("Notepad").Close
SystemUtil.Run"Notepad"
Window("Notepad").WinEditor("Edit").Click iXCord,iYCord,micRightBtn
For index2 = 1 To 4
obj.SendKeys"{DOWN}"
'Wait(1)
Next
obj.SendKeys "{ENTER}"
Set obj = CreateObject("WScript.Shell")
'Window("Notepad").Activate
iXCord = Window("Notepad").WinEditor("Edit").GetROProperty("x")
iYCord = Window("Notepad").WinEditor("Edit").GetROProperty("y")
'Window("Notepad").Activate
Window("Notepad").WinEditor("Edit").Click iXCord, iYCord,micRightBtn
For index = 1 To 6
obj.SendKeys"{UP}"
'Wait(1)
Next
obj.SendKeys"{ENTER}"
'Wait(1)
Window("Notepad").WinEditor("Edit").Click iXCord, iYCord,micRightBtn
For index1 = 1 To 3
obj.SendKeys"{DOWN}"
'Wait(1)
Next
obj.SendKeys"{ENTER}"
Window("Notepad").Close
SystemUtil.Run"Notepad"
Window("Notepad").WinEditor("Edit").Click iXCord,iYCord,micRightBtn
For index2 = 1 To 4
obj.SendKeys"{DOWN}"
'Wait(1)
Next
obj.SendKeys "{ENTER}"
Text Area Checkpoint - Desktop Check Points
Script No16: -Write a script to right click on Desktop, select Properties and validate “DESKTOP” Tab Existence in
“Display Properties Dialog” if exist then select it.
“Display Properties Dialog” if exist then select it.
Option Explicit
Dim sExpTab,iFlag,sActTab,index,obj,iXCord,iYCord,iTabCnt
sExpTab = "Desktop"
iFlag = 0
Set obj = CreateObject("WScript.Shell")
iXCord = Window("Program Manager").WinListView("SysListView32").GetROProperty("x")
iYCord = Window("Program Manager").WinListView("SysListView32").GetROProperty("y")
Window("text:=QuickTest.*").Minimize
Window("Program Manager").WinListView("SysListView32").Click iXCord,iYCord,micRightBtn
Wait(1)
obj.SendKeys"{UP}"
obj.SendKeys"{ENTER}"
iTabCnt = Dialog("Display Properties").WinTab("SysTabControl32").GetItemsCount
For index = 0 To iTabCnt-1
sActTab = Dialog("Display Properties").WinTab("SysTabControl32").GetItem(index)
If sExpTab = sActTab Then
iFlag = 1
Dialog("Display Properties").WinTab("SysTabControl32").Select sExpTab
MsgBox "Given Tab is Found and Selected"
Exit For
End If
Next
If iFlag = 0 Then
MsgBox"Given Tab is Not Found"
End If
Dim sExpTab,iFlag,sActTab,index,obj,iXCord,iYCord,iTabCnt
sExpTab = "Desktop"
iFlag = 0
Set obj = CreateObject("WScript.Shell")
iXCord = Window("Program Manager").WinListView("SysListView32").GetROProperty("x")
iYCord = Window("Program Manager").WinListView("SysListView32").GetROProperty("y")
Window("text:=QuickTest.*").Minimize
Window("Program Manager").WinListView("SysListView32").Click iXCord,iYCord,micRightBtn
Wait(1)
obj.SendKeys"{UP}"
obj.SendKeys"{ENTER}"
iTabCnt = Dialog("Display Properties").WinTab("SysTabControl32").GetItemsCount
For index = 0 To iTabCnt-1
sActTab = Dialog("Display Properties").WinTab("SysTabControl32").GetItem(index)
If sExpTab = sActTab Then
iFlag = 1
Dialog("Display Properties").WinTab("SysTabControl32").Select sExpTab
MsgBox "Given Tab is Found and Selected"
Exit For
End If
Next
If iFlag = 0 Then
MsgBox"Given Tab is Not Found"
End If


No comments :
Post a Comment