Monday, May 10, 2010

Action v/s Function

When developing an automation framework everyone thinks whether they should go for Action based Framework or Function based Framework.

Both of them has their own Pros/Cons. But Function based framework is more robust and flexible and easily maintainable. Depending on the Licensing feasibility and Resource skill set either one can decide Functions or Actions.

Major Differences
Actions
1.Actions are part of Quick Test Professional
2.Actions has their own object Repositories and Data sheets. Handling Object Repositories and Data Sheets are much easier.
3.Parameters to an Action can be passed through only Input parameters and these parameters have to declared in the Action settings.
4.Action always return Boolean. If any custom value needs to be returned then it has to be returned as Output parameter which is again part of Action Setting
5.Well Integrated with QTP. It occupies much more memory compare to Functions
6.Cannot pass the value By Ref or By Val.
7.QTP Intellisense is available
8.QTP Editor is required to write the code.

Functions
1.Purely part of VBScripting
2.No Object Repository or Data Sheets are available
3.Parameters can be passed as Byval or ByRef
4.Only one variable can be returned.
5.Independent to QTP
6.Occupies Less memory intern increases the performance of the Execution
7.Need to be associated with QTP
8.Scripting would be slow as QTP Intellisense is not available
9.QTP License is not required as we can use simple NotePad as an Editor

Monday, May 3, 2010

Sending a mail through QC using API

The below function helps to send mail from QC automatically with attachment

Public function sendMail(toMail,fromMail,subj,body,attachment)
Set qcCon = qcutil.QCConnection
qcCon.sendmail toMail,fromMail,subj,body
Set qcCon = nothing
End Function

Connecting and disconnectingto QC through API

The following function helps to connect QC

public function connectToQC(qcUserName, qcPwd, qcURL, qcDomain, qcProject)
Set tdc = CreateObject("TDApiOle80.TDConnection")
tdc.InitConnectionEx qcURL
tdc.Login qcUsername, qcPwd
tdc.Connect qcDomain, qcProject
if tdc.connected then
connectToQC = 0
else
connectToQC = 1
end if
set tdc = nothing
end function

The following function helps to disconnect from QC

public function disconnectQC()
Set tdc = CreateObject("TDApiOle80.TDConnection")
If tdc.Connected Then
tdc.Disconnect
End If
If tdc.LoggedIn Then
tdc.Logout
End If
set tdc = nothing
end function