for Beginners Simple and Golden Procedure to record and develop QTP scripts.

By | May 22, 2009

I refer many websites and check that how they can be useful for beginner student. But I came to know that there are not a single website which shows simple step by step procedure to record and develop procedure. Good news for beginner’s in QTP !!!!!!

Here I am going to describe golden procedure which you can follow to record and develop QTP script.

1. Press record button using “F3”.

2. Do the required action for your project.(for e.g open webpage,login etc)

3. stop recording using “F4”

4. Now its time to put check points, where we want to verifty results. you can take help of active screen (which shows snapshot of the object) (to see active screen click on view->active screen).

5. Now using active screen put check points according to your needs. for e.g. If you want to check property of any box you can use standard check point. If you want to check content of table you can use table check point, which can be created using standard check point. If you want to verify paritcular image you can use image check point.

6. Now its time to use some VB scripting. Before that You should know some basics like function, array, variable, If else , Do while, For loop to make your code work smartly.

7. your check point will look like this->
Window(“Microsoft Word”).WinObject(“Microsoft Word Document”).Check CheckPoint(“Microsoft Word Document_5”)

8. Now embed it in If and else loop so that you can verify the result of check point.

if (Window(“Microsoft Word”).WinObject(“Microsoft Word Document”).Check (CheckPoint(“Microsoft Word Document_5”))) then
msgbox “pass”
msgbox “fail”
end if

9. If pass appears then your check point is pass other wise fail.

10.You can develop simple script which do logging in text file.
Here I have made one script which do result logging.
This is the very important script used for result logging.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const Reports_Loacation = “C:\Reports”Dim Report_File

Sub Create_File() ‘which create reports file according to month,day,year and hour.

Report_File = “Report_” & Month(Now) & “_” & Day(now) & “_” & year(now) & “_” & hour(now) & “_” & minute(now) & “_” & second(now) & “.txt”
‘msgbox Report_File
Dim fso, MyFile
Set fso = CreateObject(“Scripting.FileSystemObject”)
If not (fso.FolderExists(Reports_Loacation)) Then
End If
Report_File = fso.BuildPath( Reports_Loacation , Report_File)
Set MyFile = fso.CreateTextFile(Report_File, True)
MyFile.WriteLine(“Test CaseNo,Status,Reason.”)
set MyFile = nothing set fso = nothing

End Sub

Public Sub Log_Report (ByVal TestCase, ByVal Status, ByVal Reason) ‘which logs result

Dim fso, MyFile
Dim RpLine
RpLine = TestCase & “,” & Status & “,” & Reason & vbnewline
Set fso = CreateObject(“Scripting.FileSystemObject”)
If (fso.fileexists(Report_File)) Then Set MyFile = fso.OpenTextFile(Report_File,ForAppending, true)
End If
Set fso = nothing Set MyFile = nothing

End Sub


In above script , Create_File function creates file according to to month, day ,year and hour. and Log_Report function do logging to text file.

11. You can log results using calling fallowing functions. It take three argument test case no, result and reason.

Create_File() ‘ Call this function to create file

12. You can also see results of chekpoint in Automation->results.

13. So If you will follow this golder procedure you will easily develop the scripts

Best of Luck!!!!!!!!!!!!!!!!

If you like this article, You can subscribe through mail.

3 thoughts on “for Beginners Simple and Golden Procedure to record and develop QTP scripts.

Leave a Reply

Your email address will not be published. Required fields are marked *