1. Private ObjFSO 'This is used to store FileSystemOb
ject Reference
Private strPvtTestCaseName 'This is used to srore T
estCaseName
Set ObjFSO = CreateObject("Scripting.FileSystemObje
ct") 'Create FileSystem Object
'#################################################
##################################################
#####################
' Library file name : fn_general.qfl
' Library file Description : Lists all the co
mmon functions that can be used across application
s :
' ################################################
##################################################
#####################
'*********FUNCTION: to close all open browsers
Function gen_closeAllBrowsers()
gen_closeAllBrowsers = False
While Browser("CreationTime:=0").Exist(0)
Browser("CreationTime:=0").Close
Wend
If NOT Browser("CreationTime:=0").Exist(2) Then
gen_closeAllBrowsers = True
End If
End Function
'*********FUNCTION: to launch a browser, returns br
owser object
Function gen_launchbrowser()
If gen_closeAllBrowsers Then
Set objIE = CreateObject("InternetExplorer.
Application")
Set gen_launchbrowser = objIE
End IF
End Function
'*********FUNCTION: to open application
Function gen_launchWebPortal(var_appUrl)
2. If gen_closeAllBrowsers Then
Set objBrowser = gen_launchbrowser()
objBrowser.visible=True
objBrowser.Navigate(var_appUrl)
End If
End Function
'*********FUNCTION: to open application
Function sap_launchWebPortal(var_appUrl)
If gen_closeAllBrowsers Then
SystemUtil.Run "iexplore",var_appUrl,,,3
End If
End Function
'*********FUNCTION: to click a link
Function gen_clickLink(obj_PageOrFrame, var_linkTex
t, var_class, var_htmlId)
Dim linkDesc,obj_linkToClick
Set linkDesc = Description.Create
linkDesc("html id").Value = var_htmlId
linkDesc("html tag").Value = "A"
linkDesc("class").Value = var_class
linkDesc("text").Value = var_linkText
Set obj_linkToClick = obj_PageOrFrame.ChildObje
cts(linkDesc)
If obj_linkToClick.Count = 1 Then
obj_linkToClick(0).click
Wait(3)
Else
Call gfReportExecutionStatus(micWarning, "
Link count mismatch", "Link is either missing or t
oo many links on page: " &var_linkText)
End If
End Function
'*****FUNCTION: to find child objects that match a
given description
Function gen_findObject(obj_pageOrFrame, arr_proper
ty, arr_value)
Set objPageOrFrame = obj_pageOrFrame
If UBound(arr_property) = UBound(arr_value) The
n
3. Set objDesc = Description.Create()
For ipropCnt = 0 to UBound(arr_property)
MsgBox arr_property(ipropCnt)&"::::"&ar
r_value(ipropCnt)
objDesc(arr_property(ipropCnt)).Value =
arr_value(ipropCnt)
Next
Set objFound = objPageOrFrame.ChildObjects(
objDesc)
MsgBox objFound.Count
For i = 0 to objFound.Count-1
MsgBox objFound(i).GetROProperty("titl
e")&":::::"&objFound(i).GetROProperty("html id")
Next
If objFound.Count=1 Then
gen_findObject = objFound(0)
Else
Call gen_printAndReport("Done", "Statu
s:Find Objects", "Too many objects or no object fo
und")
End If
End If
End Function
'*********FUNCTION: to print and report a step to t
he results
Public Function gen_printAndReport(var_eventStatus,
var_stepName, var_stepDetails)
print var_stepName&":::"&var_stepDetails
Select Case UCASE(var_eventStatus)
Case "DONE"
Reporter.ReportEvent micDone, var_stepN
ame, var_stepDetails
Case "WARN"
Reporter.ReportEvent micWarning, var_st
epName, var_stepDetails
Case "FAIL"
Reporter.ReportEvent micFail, var_stepN
ame, var_stepDetails
Case "PASS"
Reporter.ReportEvent micPass, var_stepN
ame, var_stepDetails
4. End Select
End Function
'*********FUNCTION: to create a Runtime data table,
returns the row count
Public Function gen_createRunTimeDataTable(var_SrcF
ile, var_srcSheet, var_destSheet)
DataTable.AddSheet var_destSheet
DataTable.ImportSheet var_SrcFile, var_srcS
heet, var_destSheet
gen_createRunTimeDataTable = DataTable.GetS
heet(var_destSheet).GetRowCount
End Function
'*********FUNCTION: to export the results file by a
ppending current date/time
Private Function gen_exportRunTimeDataTable(var_fil
eName)
var_fileNameWithoutExtn= Left(var_fileName,
instr(1,var_fileName,".xls")-1)
var_renameAs= val_dateForResultsFile&"_"&va
r_fileNameWithoutExtn&".xls"
DataTable.Export(val_outputData
FilePath&var_fileName)
Wait(5)
End Function
'*********FUNCTION: to import all the sheets to the
Data Table
Private Function gen_importAllSheetsFromFile(var_Sr
cFile,arr_srcSheets,arr_destSheets)
var_sheetCount = 0
For each srcSheet in arr_srcSheets
DataTable.AddSheet arr_destSheets(var_s
heetCount)
DataTable.ImportSheet var_SrcFile,srcSh
eet,arr_destSheets(var_sheetCount)
var_sheetCount = var_sheetCount+1
Next
End Function
'*********FUNCTION: to upload the image file to th
e attachments tab of a test or component in QC
Private Function gen_addAttachment(var_File)
If QCUtil.IsConnected = True Then
5. If NOT QCUtil.CurrentRun is Nothing Then
Set obj_attachPath = QCutil.CurrentRun.
Attachments
Set obj_attach = obj_attachPath.AddItem
(null)
obj_attach.FileName = var_File
Wait(2)
obj_attach.Type = 1
Wait(2)
obj_attach.Post
Wait(5)
obj_attach.Refresh
Call gen_printAndReport("Done", "Statu
s:File Upload", "Exported the runtime datatable to
QC Attachments folder in TestLab> CurrentRun")
End If
End If
Set obj_attachPath = Nothing
Set obj_attach = Nothing
End Function
'*********FUNCTION: to format the date, returns for
matted date
Private Function gen_formatDate(sFormat)
Set var_sysDate = DotNetFactory.CreateInsta
nce("System.DateTime")
Set oDate = var_sysDate.Parse(var_sysDate.N
ow.ToString)
gen_formatDate = oDate.ToString(sFormat)
Set var_sysDate = Nothing
End Function
'Environment File loading
'Call Environment.LoadFromFile("....EnvironmentE
nvironment.ini")
'#################################################
##################################################
################
'# Function: gfOnInitialize(ByVal strTestCaseName)
'# Function is used to initialize startup Resource
s like loading the Environment Repository and clos
ing all the
6. '# existing browsers except Quality center and Webe
x
'#
'# Parameters:
'# Input Parameters:
'# strTestCaseName - Name of the Test Case
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Use this procedure at the starting of the scrip
t to ensure all the browsers are closed and loadin
g the environment variables
'#
'# Usage:
'# The usage of this procedure is
'# > Call gfOnInitialize("BackOrder")
'#################################################
##################################################
################
Public Function gfOnInitialize(ByVal strTestCaseNam
e)
'UnLock WorkStation
'Call lpLockWorkStation("Disable")
'For HTML Reporting purpose Testcase name is s
tored in private variable so it will access in thi
s vbs only
strPvtTestCaseName = strTestCaseName
'Create AutomationReport Folder Structure
Call lpCreateFolderStructure(Environment("gval_
executionReportPath"))
'This will Enable all the reporting stuff
Reporter.Filter = rfEnableAll
'Reporting Test Case Name for providing more de
tails only in QTP Report
Reporter.ReportEvent micInfo, "TestCase: "&strT
estCaseName, "TestCase: "& strTestCaseName
'For InBuilt QTP Reporting Purpose
7. 'Call lpCustomReport(micInfo, strTestCaseName,
strTestCaseName)
'This will disable all the reporting stuff
' Reporter.Filter = rfDisableAll
'Close All Open Browsers
Call gfCloseAllBrowsers()
'Load Environment
Call lpLoadEnvironmentRepository()
End Function
'#################################################
##################################################
################
'# Function: gfOnTerminate()
'# Function is used to terminate the resources lik
e closing all the existing browsers and Generating
HTML Report
'#
'# Parameters:
'# Input Parameters:N/A
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Call this procedure at the end of the script to
Close the browser and generate the HTML report
'#
'# Usage:
'# The usage of this procedure is
'# > Call gfOnTerminate()
'#################################################
##################################################
################
Public Function gfOnTerminate()
'Cleaning up recordset memory
Set gLangObjIDRs = Nothing
8. 'Close all open browsers
Call gfCloseAllBrowsers()
'This is used to generate Html report
Call lpGenerateHtmlReport()
Call gflpGenerateHtmlReport()
Call lpDeleteFolders()
'Clean Up memory
strPvtTestCaseName = Empty
End Function
'#################################################
##################################################
################
'# Function: lpLockWorkStation(strEnableDisable)
'# This Function is used to Lock and UnLock the Sys
tem
'#
'# Parameters:
'# Input Parameters:strEnableDisable
'# If strEnableDisable=Disable Then UnLock The Syet
m
'# If strEnableDisable=Enable Then Lock The Syetm
'# OutPut Parameters: N/A
'#
'# Remarks:
'# This Function is used to Lock and UnLock the Sys
tem
'#
'# Usage:
'# The usage of this procedure is
'# > Call lpLockWorkStation("Disable") Or Call lpLo
ckWorkStation("Enable")
'#################################################
##################################################
################
Private Sub lpLockWorkStation(strEnableDisable)
Dim objShell 'ShellObject
'Create Shell Object
9. Set objShell = CreateObject("WScript.Shell")
If(UCase(strEnableDisable)="DISABLE") Then
'Lock WorkStation
objShell.RegWrite "HKCUSoftwareMicrosoft
WindowsCurrentVersionPoliciesSystemDisableLoc
kWorkstation", 00000001, "REG_DWORD"
ElseIf(Ucase(strEnableDisable)="ENABLE") Then
'UnLock WorkStation
objShell.RegWrite "HKCUSoftwareMicrosof
tWindowsCurrentVersionPoliciesSystemDisableLo
ckWorkstation", 00000000, "REG_DWORD"
End If
Set objShell = Nothing
End Sub
'#################################################
##################################################
################
'# Function: lpCreateFolderStructure(strStructurePa
th)
'# This Function is used to Create Folder Structure
'#
'# Parameters:
'# Input Parameters:strStructurePath - folder path
that needs to be created
'# OutPut Parameters: N/A
'#
'# Remarks:
'# This Function is used to Create Folder Structure
'#
'# Usage:
'# The usage of this procedure is
'# > Call lpCreateFolderStructure("C:AutomationRes
ultScreenShots")
'#################################################
##################################################
################
10. Private Sub lpCreateFolderStructure(gval_executionR
eportPath)
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemOb
ject")
If Not oFSO.FolderExists(gval_executionReportPa
th) Then
oFSO.CreateFolder gval_executionReportPath
End If
End Sub
'#################################################
##################################################
##################
'# Function: gfCloseAllBrowsers()
'# This Function is used to close all open browsers
except Quality center and WebEx.
'#
'# Parameters:
'# Input Parameters:N/A
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# This Function is used to close all open browsers
except Quality center and WebEx.
'#
'# Usage:
'# The usage of this Procedure is
'# blnStatus = gfCloseAllBrowsers()
'#################################################
##################################################
##################
Public Function gfCloseAllBrowsers()
Err.Clear
Dim objDesc,browserElements,numOfBrowsers,intCn
t
Dim strFuncName 'Procedure Name while displayin
g the Fail error message details
11. strFuncName = "Error in gfCloseAllBrowsers():"
'Close all the Dialogs and Windows that are ope
n
Call lpcloseAllDialogs()
'Retrive all Browsers from Desktop
Set objDesc = Description.Create()
objDesc("micClass").Value = "Browser"
' Set browserElements = Desktop.ChildObjects(objD
esc)
' numOfBrowsers = browserElements.Count
'Close all browsers except Quality Center
If Desktop.ChildObjects(objDesc).Count > 0 Then
For x = Desktop.ChildObjects(objDesc).Count - 1
To 0 Step -1
If InStr(1, Browser("creationtime:="&x).Get
ROProperty("title"), "Quality Center") = 0 And InS
tr(1, Browser("creationtime:="&x).GetROProperty("t
itle"), "WebEx Client Entry") = 0 And InStr(1, Br
owser("creationtime:="&x).GetROProperty("title"),
"Microsoft Office Live Meeting") = 0 Then
Browser( "creationtime:=" & x ).Close
End If
Next
End If
'Closes the Browser window (or tab) except Qual
ity Center and WebEX
' For intCnt = 0 To numOfBrowsers - 1
' If (InStr(browserElements(intCnt).GetROPro
perty("title"),"Quality Center") = 0 And InStr(bro
wserElements(intCnt).GetROProperty("title"),"WebEx
Client Entry") = 0 And InStr(browserElements(intC
nt).GetROProperty("title"),"Microsoft Office Live
Meeting") = 0 ) Then
' If (browserElements(intCnt).GetROProper
ty("disabled") = 0) Then
' browserElements(intCnt).Close
12. ' End If
' End If
' Next
'
' Set browserElements = Nothing
Wait(1)
' 'Check whether all open browsers are closed or
not except Quality Center and WebEX
' Desktop.ChildObjects(oDesc).Count = 0
' Set browserElements = Desktop.ChildObjects(objD
esc)
' numOfBrowsers = browserElements.Count
' If(numOfBrowsers > 0) Then
' For intCnt = 0 To numOfBrowsers - 1
' If (InStr(browserElements(intCnt).GetR
OProperty("title"),"Quality Center") = 0 And InStr
(browserElements(intCnt).GetROProperty("title"),"W
ebEx Client Entry") = 0 ) Then
' If(browserElements(intCnt).GetROPro
perty("disabled") = 0 ) Then
' Call gfReportExecutionStatus(m
icFail,strFuncName , "Unable to close the browser
" & browserElements(intCnt).GetROProperty("title"))
' End If
' End If
' Next
' End If
Set objDesc = Nothing
'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Function
'#################################################
##################################################
################
13. '# Function: lpLoadEnvironmentRepository()
'# Function is used to Load Environment Repository
'#
'# Parameters:
'# Input Parameters: N/A
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Loads the environment variables values present
in the environment repository to the global variab
les
'#
'# Usage:
'# The usage of this procedure is
'# > Call lpLoadEnvironmentRepository()
'#################################################
##################################################
################
Private Sub lpLoadEnvironmentRepository()
Dim strFuncName 'Procedure Name while displayin
g the Fail error message details
strFuncName = "Error in lpLoadEnvironmentReposi
tory():"
Err.Clear
'Read from Environment and Store in Global vari
ables
gstrBrowserType = Environment("browserType")
gSYNCWAIT = CInt(Environment("syncWait"))
gSHORTWAIT =CInt(Environment("shortWait"))
gMEDIUMWAIT = CInt(Environment("mediumWait"))
gLONGWAIT = CInt(Environment("longWait"))
gDELAYINTERVAL = CInt(Environment("delayInterva
l"))
gTIMEOUT = CInt(Environment("timeOut"))
' gLanguage = Environment("LanguageID")
' gLangExcelPathObjectID = Environment("LangExce
lPathObjectID") 'To retrieve the Object ID Excel
Path
' gLangObjIDSheetName = Environment("LangObjectI
DExcelSheetName") 'To retrieve the propert
14. ies data from the sheet
'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Sub
'#################################################
##################################################
################
'# Function: gfBrowserSync()
'# This Function is used to Wait Until BrowserPage
Loaded
'#
'# Parameters:
'# Input Parameters: N/A
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Procedure waits until the browser and page loads
completely
'#
'# Usage:
'# The usage of this procedure is
'# > Call gfBrowserSync()
'#################################################
##################################################
################
Public Function gfBrowserSync()
Err.Clear
Dim strFuncName 'Procedure Name while displayin
g the Fail error message details
Dim intCnt 'Counter for Browser Sync
strFuncName = "Error in gfBrowserSync():"
On Error Resume Next
15. Dim objBrowser,objPage,browserObjects,intBrows
ersCount,intBrowserIndex,pageObjects,intPagesCount
,intPageIndex
'Using DP Create Browser and page Objects
Set objBrowser = Description.Create()
objBrowser("micClass").Value = "Browser"
Set objPage = Description.Create()
objPage("micClass").Value = "Page"
'Retrive Browser Objects from DeskTop
Set browserObjects = Desktop.ChildObjects(objBr
owser)
intBrowsersCount = browserObjects.Count
'verifies for the Browser Count
If(intBrowsersCount > 0) Then
For intBrowserIndex = 0 To intBrowsersCount
- 1
If (InStr(browserObjects(intBrowserInd
ex).GetROProperty("title"),"Quality Center") = 0 A
nd InStr(browserObjects(intBrowserIndex).GetROProp
erty("title"),"WebEx Client Entry") = 0 ) Then
'Call Browser Sync For IE
If InStr(browserObjects(intBrowser
Index).GetROProperty("version"),"internet explorer
") > 0 Then
For intCnt = 0 To gSYNCWAIT
If browserObjects(intBrowse
rIndex).Object.ReadyState = 4 Then
Exit For
End If
Wait(1) 'Waiting for gSyncW
ait number of seconds
Next
Else
browserObjects(intBrowserIndex)
.Sync
End If
Set pageObjects = browserObjects(in
tBrowserIndex).ChildObjects(objPage)
intPagesCount = pageObjects.count
16. If (intPagesCount > 0) Then
For intPageIndex = 0 To intPage
sCount - 1
'Call Page Sync
pageObjects(intPageIndex).S
ync
Next
End If
End If
Next
End If
'Clean Up memory
Set objBrowser = Nothing
Set objPage = Nothing
Set browserObjects = Nothing
Set pageObjects = Nothing
Err.Clear
End Function
'#################################################
##################################################
################
'# Function: gfExitAction()
'# Function is used to Exit from Current Action
'#
'# Parameters:
'# Input Parameters:
'# strStepName - Step Name to report
'# strStepDetails - Step details to report
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Reports the fail message and terminates all the
existing applications and exiting from the curren
t action
'#
'# Usage:
'# The usage of this procedure is
17. '# > Call gfExitAction("Failed to find the object s
earchby")
'#################################################
##################################################
################
Public Function gfExitAction(ByVal strStepName, ByV
al strStepDetails)
'Call Report Event
Call gfReportExecutionStatus(micFail,strStepNam
e,strStepDetails)
'Before Exit from current Action call gfOnTermi
nate() procedure
'Call gfOnTerminate()
'Exit from Current Action
'On Error GoTo 0
'ExitAction((Environment("ActionName")))
End Function
'#################################################
##################################################
################
'# Function: gfReportExecutionStatus(ByVal intStatu
s,ByVal strStepDetails)
'# Function is used to report Pass/Fail/Done/Warnin
g messages in QTP inbuilt report
'#
'# Parameters:
'# Input Parameters:
'# intStatus - Pass/Fail/Info/Warned Status
'# strStepDetails - Step details to report
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# intStatus Parameter can be 0/1/2/3 or micPass,mi
cFail,micDone,micWarning
'#
'# Usage:
18. '# The usage of this procedure is
'# > Call gfReportExecutionStatus(micPass,"Expecte
d object displayed in Shopping cart page")
'#################################################
##################################################
################
Public Function gfReportExecutionStatus(ByVal intS
tatus,ByVal strStepName, ByVal strStepDetails)
Dim strImagePath 'Stores Image Path
Dim strStepNameNew
'This will enable all the reporting stuff For I
nBuilt QTP Reporting Purpose
Reporter.Filter = rfEnableAll
If Len(Trim(strStepName)) >0 Then
strStepNameNew=strStepName
If Len(Trim(gstrStepName)) >0 Then
strStepNameNew=gstrStepName & " " & str
StepName
End If
Else
strStepNameNew=gstrStepName
gstrStepName=""
End If
'This will report Pass/Fail/Done/Warning messa
ges in QTP inbuilt report and Text File
Select Case intStatus
Case 0,micPass:
'This will generate Cutom QTP inBuilt R
eport
Reporter.ReportEvent micPass,strStepNam
eNew,strStepDetails
'Call lpCustomReport(micPass,strStepNam
e,strStepDetails,"SUBROOT")
'This will generate Txt Trport
'Call lpGenerateTxtReport(0,Replace(st
rStepNameNew,vbCr,""),Replace(strStepDetails,vbCr,
""))
Case 1,micFail:
strImagePath = lfCaptureImage()
19. strStepDetails = strStepDetails & " -
- For More Details, Refer Screenshot at " & strIma
gePath
'This will generate Cutom QTP inBuilt R
eport
'Call lpCustomReport(micFail,gstrStepNa
me,strStepDetails,"SUBROOT")
Reporter.ReportEvent micFail,strStepNam
eNew,strStepDetails,strImagePath
'Call lpGenerateTxtReport(1,Replace(st
rStepNameNew,vbCr,""),Replace(strStepDetails,vbCr,
""))
Case 2,micDone:
' If(CBool (Environment("debugMode"))) Th
en
'This will generate Cutom QTP inBui
lt Report
'Call lpCustomReport(micDone,strSte
pDetails,"SUBROOT")
Reporter.ReportEvent micDone,gstrSt
epName,strStepDetails
'Call lpGenerateTxtReport(2,Replac
e(strStepNameNew,vbCr,""),Replace(strStepDetails,v
bCr,""))
' End If
Case 3,micWarning:
'This will generate Cutom QTP inBuilt R
eport
'Call lpCustomReport(micWarning,strStep
Name,strStepDetails,"SUBROOT")
Reporter.ReportEvent micWarning,gstrSte
pName,strStepDetails
'Call lpGenerateTxtReport(3,Replace(st
rStepNameNew,vbCr,""),Replace(strStepDetails,vbCr,
""))
End Select
'This will disable all the reporting stuff
' Reporter.Filter = rfDisableAll
End Function
'#################################################
20. ##################################################
##################
'# Function: gfClickObject(ByRef objControl)
'# This Function is used to click on the object fo
llowing controls like Link,Image,WebButton,WebElem
ent,WebRadioGroup
'# WinButton
'#
'# Parameters:
'# Input Parameters:
'# objControl - Object on which action to be perfor
med
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Clicks on the Object if Exist and Enabled else e
xits from the current action
'#
'# Usage:
'# The usage of this Procedure is
'# blnStatus = gfClickObject(Browser("brSOSDesignT
ools").Page("pgProductPage").Webbutton("btnSearch"
))
'#################################################
##################################################
##################
Public Function gfClickObject(ByRef objControl)
Err.Clear
Dim strTestObjectName
Dim strFuncName 'Procedure Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in gfClickObject():"
strTestObjectName = lfToString(objControl)
'Re-identify the object in the application the
next time a step refers to this object
'objControl.RefreshObject
'check whether object objControl is exists or n
21. ot
If(gfObjectExists(objControl))Then
gfReportExecutionStatus micDone, strFuncNa
me ,"Object [" & strTestObjectName & "] Exist"
'check whether object objControl is enabled
or not
If (gfIsEnabled(objControl)) Then
gfReportExecutionStatus micDone, strFu
ncName , "Object [" & strTestObjectName & "]is in
Enabled State"
'Retrive objControl micClass
Select Case objControl.GetROProperty("m
icClass")
Case "WebButton","Link","Image","W
ebElement","WebRadioGroup","WinButton","WebCheckBo
x"
'objControl.Highlight
objControl.Click
gfReportExecutionStatus micD
one, strFuncName ,"Object [ " & strTestObjectName
& " ] is clicked!"
'Waits for the Browser/Page
to complete the current navigation.
End Select
Else
'If objControl is not exists then Exit
from current Action
On Error GoTo 0
Call gfExitAction(strFuncName ,"Object
[" & strTestObjectName & "[ is not in Enabled Sta
te")
End If
Else
'If objControl is not enabled then Exit fro
m current Action
On Error GoTo 0
Call gfExitAction(strFuncName , "Object ["
& strTestObjectName & "] dose not Exist")
End If
Call gfSyncApplication(objControl.GetROProperty
("micClass"))
22. 'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Function
'#################################################
##################################################
################
'# Function: gfOpenBrowser(ByVal strBrowserType, By
Val strURL)
'# Function is used to open the browser
'#
'# Parameters:
'# Input Parameters:
'# strBrowserType - Browser to be used to open the
url
'# strURL - Application URL to be opened
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Used to open the Browser
'#
'# Usage:
'# The usage of this Procedure is
'# > Call gfOpenBrowser("IE","http://google.com")
'#################################################
##################################################
##################
Public Function gfOpenBrowser(ByVal strBrowserType,
ByVal strURL)
Err.Clear
Dim strFuncName 'Procedure Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in gfCloseAllBrowsers():"
23. Select Case UCase(strBrowserType)
Case gCnstIEBrowser
'SystemUtil.Run "iexplore.exe",strURL
SystemUtil.Run "iexplore.exe",strURL,
, ,3
Case gCnstFFBrowser
SystemUtil.Run "firefox.exe",strURL
End Select
'Waits for the Browser/Page to complete the cur
rent navigation.
Call gfBrowserSync()
'This is used to maximize Browser
'Call lpBrowserMaximize(Browser(Browser))
'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Function
'#################################################
##################################################
################
'# Function: gfDeleteResults(var_FolderPath)
'# Function is used to delete contents in folder
'#
'# Parameters:
'# Input Parameters:
'# var_FolderPath - Folder Path
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'#
'# Usage:
'# The usage of this Procedure is
24. '# > Call gfDeleteResults(var_FolderPath)
'#################################################
##################################################
##################
Public Function gfDeleteResults(var_FolderPath)
Dim Objfolder
Dim aFile
Set Objfolder = ObjFSOReport.GetFolder(var_FolderPa
th)
For Each aFile In Objfolder.Files
aFile.Delete
Next
End Function
'#################################################
##################################################
################
'# Function:gfUploadResults(var_FolderPath)
'# FUNCTION: to upload the Results HTML Report, Te
xt File, and screen shots to the attachments tab
of a test or component in QC
'#
'# Parameters:
'# Input Parameters:
'# var_FolderPath - Results path
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'#
'# Usage:
'# The usage of this Procedure is
'# > Call gfUploadResults(var_FolderPath)
'#################################################
##################################################
##################
Public Function gfUploadResults(var_FolderPath)
Err.Clear
Dim Objfolder
Dim aFile
Set Objfolder = ObjFSOReport.GetFolder(var_Fold
erPath)
25. For Each aFile In Objfolder.Files
Call gfaddAttachment(aFile)
Next
End Function
'*********FUNCTION: to upload the files to the atta
chments tab of a test or component in QC
Public Function gfaddAttachment(var_File)
Dim obj_attachPath,obj_attach
If QCUtil.IsConnected = True Then
If NOT QCUtil.CurrentRun is Nothing Then
Set obj_attachPath = QCutil.CurrentRun.
Attachments
Set obj_attach = obj_attachPath.AddItem
(null)
obj_attach.FileName = var_File
Wait(2)
obj_attach.Type = 1
Wait(2)
obj_attach.Post
Wait(5)
obj_attach.Refresh
End If
End If
Set obj_attachPath = Nothing
Set obj_attach = Nothing
End Function
'**************************************************
****************************************
'#################################################
##################################################
################
'#################################################
##################################################
################
'# Function is used to Maximize the Browser
'#
'# Parameters:
'# Input Parameters:
'# objBrowser - Browser to be maximized
26. '#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Remarks:
'# Usage:
'# The usage of this Procedure is
'# > Call gpBrowserMaximize(Browser("brSOSDesignToo
ls"))
'#################################################
##################################################
##################
Private Sub lpBrowserMaximize(ByRef objBrowser)
Err.Clear
Dim strFuncName 'Procedure Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in lpBrowserMaximize():"
'On Error Resume Next
Dim hWnd
'Verify whether Browser type is firefox or Inte
rnet explorer
If(UCase(gstrBrowserType) = "FIREFOX") Then
Window("Mozilla Firefox").Maximize
ElseIf(UCase(gstrBrowserType) = "INTERNET EXPLO
RER") Then
hWnd = objBrowser.GetROProperty("hwnd")
Window("hwnd:=" & hWnd).Activate
If(Err.Number <> 0) Then
hWnd = Browser("hwnd:=" & hWnd).Object.
hWnd
Window("hwnd:=" & hWnd).Activate
Err.Clear
End If
Window("hwnd:=" & hWnd).Maximize
End If
'Check and Report Runtime Errors If any
27. If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Sub
'#################################################
##################################################
################
'# Function: lfCaptureImage()
'# Procedure used to save application failure image
when the script fails
'#
'# Parameters:
'# Input Parameters: N/A
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Captures the Image and Stores in the folder Capt
ureImages under executionReportPath
'#
'# Usage:
'# The usage of this Procedure is
'# > Call lfCaptureImage()
'#################################################
##################################################
##################
Private Function lfCaptureImage()
Err.Clear
Dim strImagesLoc,strImage,strImageSno,strReport
Path
Dim strFuncName 'Procedure Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in lfCaptureImage()"
lfCaptureImage = ""
28. If(InStr(gval_executionReportPath,":")>0) Then
strImagesLoc = gval_executionReportPath
Else
strImagesLoc = Split(Environment("ProductD
ir"),":")(0) & ":" & gval_executionReportPath
End If
strImageSno = Environment("ActionName")
If InStr(Environment("ActionName"), " [") > 0 T
hen
strImageSno = Trim(Split(strImageSno, " [")
(0))
End If
strImageSno = strImageSno & "_" & Year(Now) &
gfNumberFormat(Month(Now),"00") & gfNumberFormat(D
ay(Now),"00") & "_" & gfNumberFormat(Hour(Now) ,"0
0") & gfNumberFormat(Minute(Now),"00") & gfNumberF
ormat(Second(Now),"00") & ".png"
'Saves a screen capture of the deskTop as a .pn
g Image
strImage = strImagesLoc & Chr(92) & strImageSno
Desktop.CaptureBitmap strImage,True
lfCaptureImage = strImage
'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
' Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Function
'#################################################
##################################################
################
'# Function: lpGenerateTxtReport(ByVal intStatus,B
yVal strStepName,ByVal StrStepDescription)
29. '# Function is used to Generate Text Report
'#
'# Parameters:
'# Input Parameters:
'# intStatus - Pass/Fail status
'# strStepName-Step Name
'# StrStepDescription - Step description
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Generates text report
'#
'# Usage:
'# The usage of this Procedure is
'# > Call lpGenerateTxtReport("micPass","verify th
e mesage displayed in Shopping Cart page","Failed
to find the expected message")
'#################################################
##################################################
##################
Private Sub lpGenerateTxtReport(ByVal intStatus,ByV
al strStepName,ByVal StrStepDescription)
Err.Clear
'On Error Resume Next
Dim objTxtFile 'Objec
t to reference a file
Dim strStatus 'St
ring variable to hold the status of an action
Dim strOSInfo 'Stri
ng variable to hold the Operating system informati
on
Dim blnNewResult 'Boolean var
iable to hold the result
Dim strReportFileName 'String variable t
o hold the log file name
Dim strLogFileName 'String varia
ble to hold the log file name including path
Dim strReportPath 'String vari
30. able to hold the path of log file folder
Dim strMATCName 'String varia
ble to hold the Module,Action and TestCaseName
Dim objDateTime
Set objDateTime = DotNetFactory("System.DateTim
e")
'Initialize variables
'strMATCName = Split(Trim(Environment("TestNam
e")),"_")(1) & " $" & Trim(Environment("ActionNa
me") )& "$" & strPvtTestCaseName
strMATCName = gval_componentName
Environment("executionReportPath") = gval_execu
tionReportPath
If(Instr(Environment("executionReportPath"),":"
) > 0) Then
strReportPath = Split(Environment("executio
nReportPath"),"ScreenShots")(0)
Else
strReportPath = Split(Environment("Product
Dir"),":")(0) & Split(Environment("executionReport
Path"),"ScreenShots")(0)
End If
'strReportPath = Environment("executionReportPa
th")
'strReportFileName = Environment("reportTxtFile
Name")
strReportFileName = gval_reportTxtFileName
blnNewResult = False
strLogFileName = strReportPath & Chr(92) & strR
eportFileName & ".txt"
If (intStatus = 0) Then
strStatus = "Pass"
ElseIf (intStatus = 1) Then
strStatus = "Fail"
ElseIf (intStatus = 2) Then
strStatus = "Done"
31. ElseIf (intStatus = 3) Then
strStatus = "Warning"
End If
'Appending log to the report
strStepName = Chr(34) & strStepName & Chr(34)
StrStepDescription = Chr(34) & StrStepDescripti
on & Chr(34)
'Create Txt Log File if not exists
If (Not(ObjFSO.FileExists(strLogFileName))) The
n
Set objTxtFile = ObjFSO.OpenTextFile(strLog
FileName,8,True)
objTxtFile.WriteLine ""
objTxtFile.WriteLine vbTab & gval_htmlRepo
rtSuiteName & " Automation Test Suite Log"
objTxtFile.Close
Set objTxtFile = Nothing
blnNewResult = True
End If
'Opens the Text file
Set objTxtFile = ObjFSO.OpenTextFile(strLogFile
Name,8,True)
If(strMATCName <> gval_PrevTCName) Then
'End of every TestCase it's generate End ti
me
If(ObjFSO.FileExists(strLogFileName) And bl
nNewResult = False) Then
objTxtFile.WriteLine "End Time:" & vbT
ab & objDateTime.Now.toString("MM/dd/yyyy hh:mm:ss
tt")
objTxtFile.WriteLine ""
End If
'At the time of new TestCase starts
objTxtFile.WriteLine "Test Case Name: " & v
bTab & strMATCName
strOSInfo = Environment("LocalHostName") &
" " & Environment("OS") & " " & Environment("OSVe
rsion")
objTxtFile.WriteLine "Environment Name: "
32. & vbTab & """" & Trim(Mid(strOSInfo, InStr(1, strO
SInfo, ":") + 1)) & """"
objTxtFile.WriteLine "Start Time:" & vbTab
& objDateTime.Now.toString("MM/dd/yyyy hh:mm:ss
tt")
objTxtFile.WriteLine ""
objTxtFile.WriteLine "S.No" & vbTab & "Sta
tus" & vbTab & "Step Name" & vbTab & "Description"
& vbTab & "Date/Time"
gval_PrevTCName = strMATCName
gval_intLogSNO = 1
End If
'Generate Log messages into text file
objTxtFile.WriteLine gval_intLogSNO & vbTab &
strStatus & vbTab & Replace(Replace(Replace(strSt
epName,VbTab,""),vbCr,""),vbLf,"") & vbTab & Repla
ce(Replace(Replace(StrStepDescription,VbTab,""),vb
Cr,""),vbLf,"") & vbTab & objDateTime.Now.toString
("MM/dd/yyyy hh:mm:ss tt")
gval_intLogSNO = gval_intLogSNO + 1
objTxtFile.Close
Set objTxtFile = Nothing
Set objDateTime = Nothing
Err.Clear
End Sub
'#################################################
##################################################
################
'# Procedure: lpGenerateHtmlReport()
'# This Procedure is used to Generate Html Report
'#
'# Parameters:
'# Input Parameters:N/A
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Generates the HTML report
33. '#
'# Usage:
'# The usage of this Procedure is
'# > Call lpGenerateHtmlReport()
'#################################################
##################################################
##################
Public Function gflpGenerateHtmlReport()
Dim qtApp
Dim qtLibraries
Dim strHTMLReport
Dim intCount
Dim blnFound
Err.Clear
'On Error Resume Next
Dim strExecutionReportPath,strTxtFilePath,strH
tmlFilePath,strDateTime,strTxtFileName,strHtmlFile
Name
'strDateTime = Year(Now) &"-" & Month(Now) & "
-" & Day(Now) & "_" & Hour(Now) & "-" & Minute(Now
) & "-" & Second(Now)
'Execution Report path,Text file name and Html
file name
If(Instr(gval_executionReportPath,":") > 0) The
n
strExecutionReportPath = Split(gval_executi
onReportPath,"ScreenShots")(0)
Else
strExecutionReportPath = Split(gval_execut
ionReportPath,":")(0) & Split(gval_executionReport
Path,"ScreenShots")(0)
End If
'strExecutionReportPath =Environment("execution
ReportPath")
strTxtFileName = gval_reportTxtFileName
strHtmlFileName = gval_htmlReportSuiteName
34. strTxtFilePath = Replace(strExecutionReportPat
h & Chr(92) & strTxtFileName & ".txt","","")
strHtmlFilePath = Replace(strExecutionReportPa
th & Chr(92) & strHtmlFileName & ".html","","")
'Loading the Report the HTMLReport.QFL file at
run time
blnFound=True
' Set qtApp = CreateObject("QuickTest.Application
")
' Set qtLibraries = qtApp.BusinessComponent.Setti
ngs.Resources.Libraries
' 'Set qtLibraries = qtApp.Test.Settings.Resource
s.Libraries
' For intCount = 1 To qtLibraries.Count
' If InStr(UCase(qtLibraries.Item(intCount)),
UCase("Generic.qfl")) > 0 Then
' blnFound=True
' strHTMLReport = Replace(qtLibraries.It
em(intCount),"Generic.qfl","HtmlReport.qfl")
' Call LoadFunctionLibrary(strHTMLReport)
' Exit For
' End If
' Next
strHTMLReport = "[QualityCenterResources] Reso
urcessap-automationlibHtmlReport.qfl"
Call LoadFunctionLibrary(strHTMLReport)
If blnFound=True Then
'initialize Html Report
Call lpInitializeHtmlReport(strTxtFilePath,
strHtmlFilePath)
End If
'Execution Result Upload to QC
'Call gfUpLoadAttachmentToQC(strHtmlFilePath)
Err.Clear
End Function
35. '#################################################
##################################################
##################
'# Function: gfGetExcelRecordSet(ByVal strExcelFil
eName, ByVal strSheetName, ByVal strWhereClause,
ByRef ObjADORecordSet, ByVal blnReadOnly)
'# Reads the data from excel and populates a record
set
'#
'# Parameters:
'# Input Parameters:
'# strExcelFileName - Excel file name with path or
QTP relative path
'# strSheetName - Excel Sheet name
'# strWhereClause - Where Clause with or without co
nditions
'# blnReadOnly - True/False (User True when you ne
ed to update the RecordSet else use False)
'#
'# OutPut Parameters:
'# ObjADORecordSet - ADODB RecordSet Object is retu
rned
'#
'# Remarks:
'# Path of the Excel file can be a relative path l
ike "....Test.xls" or actual path "C:Test.xls"
'# This Procedure will create a valid sql statement
internally
'# "Where" clause need not be entered in the Where
Condition, Procedure will interally append "Where
" to the sql statement
'# This Procedure will return an ADODB RecordSet a
nd avail the advantages of ADODB RecordSet like Mo
veNext, MoveFirst, MoveLast etc.,
'#
'#
'# Usage:
'# The usage of this Procedure is
'#
'# Example 1: Using below code you can open the fil
e for updaing any row based
'# Call gfGetExcelRecordSet("..TestDataSample.xl
36. s","Sheet1","ID=20",ObjADORecordSet,False)
'# ObjADORecordSet("ScriptStatus") = "True" 'Updat
es the field 'ScriptStatus' with 'True' in the exc
el Sheet
'# ObjADORecordSet.Update
'# objRS.Close
'#
'# Example 2: Below code will get the ADODB recored
set in read-only mode
'# Call gfGetExcelRecordSet("..TestDataSample.xls
","Sheet1","ID=20",ObjADORecordSet,True)
'# Do While Not ObjADORecordSet.EOF
'# msgbox ObjADORecordSet.Fields(0).Value
'# ObjADORecordSet.MoveNext
'# Next
'#################################################
##################################################
##################
Public Function gfGetExcelRecordSet(ByVal strExcel
FileName, ByVal strSheetName, ByVal strWhereClaus
e, ByRef ObjADORecordSet, ByVal blnReadOnly)
'Local variable declarations
Dim strQuery 'Stores SQL Query
Dim ObjCon 'ADO Connection Object
Dim strConvExcelFile
Dim gCnstExcelConnString
Dim strExcelFilePath
Dim qtApp
Dim strFuncName 'Procedure Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in gfGetExcelRecordSet():"
'Download TestData Attachement
' If(QCUtil.IsConnected) Then
' Set qtApp = CreateObject("QuickTest.Applica
tion")
' If InStr(qtApp.Test.Location, "[QualityCent
er]") > 0 Then
' strExcelFileName = gfQCAttachmentDownlo
37. ad(strExcelFileName)
' End If
' Set qtApp = Nothing
' End If
If InStr(strExcelFileName, "..") > 0 Then
strConvExcelFile = gfGetRelativePath(strExc
elFileName)
Else
strConvExcelFile = strExcelFileName
End If
'Open the Database connection
Set ObjCon = CreateObject("ADODB.Connection")
If blnReadOnly = False Then
gCnstExcelConnString = "Provider=Microsoft
.Jet.OLEDB.4.0; Data Source=""" & strConvExcelFile
& """;Extended Properties=""Excel 8.0;HDR=Yes"""
'Connection string
Else
gCnstExcelConnString = "Provider=Microsoft
.Jet.OLEDB.4.0; Data Source=""" & strConvExcelFile
& """;Extended Properties=""Excel 8.0;HDR=Yes;IME
X=1""" 'Connection string
End If
ObjCon.Open gCnstExcelConnString
strQuery = "SELECT * FROM [" & strSheetName & "
$]"
If Len(Trim(strWhereClause)) > 0 Then
strQuery = strQuery & " WHERE " & CStr(strW
hereClause)
End If
'Open the record set
Set ObjADORecordSet = CreateObject("ADODB.Recor
dset")
ObjADORecordSet.ActiveConnection = ObjCon
'To set cursortype and locktype to a editing re
cords when flag is flase
If blnReadOnly = False Then
ObjADORecordSet.CursorType = 3
'Static cursor.
ObjADORecordSet.LockType = 2
38. 'Pessimistic Lock.
End If
ObjADORecordSet.Source = strQuery
ObjADORecordSet.Open
If Not ObjADORecordSet.EOF Then
ObjADORecordSet.MoveFirst
Else
Call gfExitAction(strFuncName , "No Records
found")
End If
End Function
'#################################################
##################################################
##################
'# Function: gfGetDBRecordSet_Wait(ByVal strConStr
ing, ByVal strQuery, ByRef ObjRecordSet, ByVal int
TryTimes, ByVal blnWaitForRecordSet)
'# Procedure used to Check for the existence of ass
et in database for specified time
'#
'# Parameters:
'# Input Parameters:
'# strConString - name of server
'# strQuery - valid "Select" Statement
'# ObjRecordSet - returns the record set value if a
sset exists in database
'# intTryTimes - Tries to get the record set for Nu
mber of times
'# blnWaitForRecordSet - Boolean value (True/False)
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# This Procedure checks for the existence/non- ex
istence of asset in database for valid "Select" st
atement.
'# If blnWaitForRecordSet is passed as true, Proce
dure checks for the existence of asset in database
and
39. '# if blnWaitForRecordSet is passed as false, Proc
edure checks for the non-existence of asset in dat
abase for specified time.
'#
'# Usage:
'# The usage of this Procedure is
'# intResult = f_ GetDBRecordSet_Wait ("DRIVER={IB
M DB2 ODBCDRIVER};UID=devsqs7;PWD=lowes@48;AUTHENT
ICATION=SERVER;PORT=3910;HOSTNAME=DB2GWT;PROTOCOL=
TCPIP;DATABASE=DB2DSNQ;", "Select display_name Fro
m test_rep_1_1 Where displayname ='AssetNew1'" , s
trReturnRecSet,60,True)
'#################################################
##################################################
##################
Public Function gfGetDBRecordSet_Wait(ByVal strCon
String, ByVal strQuery, ByRef ObjRecordSet, ByVal
intTryTimes, ByVal blnWaitForRecordSet)
'Variable Declarations
Dim objCon
Dim ObjADORecordSet
Dim intSeconds
Dim blnFalg
Dim strFuncName 'Procedure Name is stored for d
isplaying the Fail error message details
Err.Clear
strFuncName = "Error in gfGetDBRecordSet_Wait()
:"
On Error Resume Next
'Variable assignment
gfGetDBRecordSet_Wait = False
blnFalg = False
If intTryTimes= 0 Then
intTryTimes = 1
End If
'Decrypt Password and rebuild connection string
strConString=gpBuildConnectionstring(strConStri
ng)
40. For intSeconds = 1 To intTryTimes
Set objCon = CreateObject("ADODB.Connection
")
Set ObjADORecordSet = CreateObject("ADODB.R
ecordSet")
objCon.ConnectionString = strConString
objCon.CommandTimeout = 3000
objCon.Open
'ObjADORecordSet.CursorType = adOpenStatic
ObjADORecordSet.Open strQuery, objCon
If Err.Number <> 0 Then
On Error GoTo 0
Call gfExitAction(strFuncName , "Unable
to execute the query :" & strQuery)
ElseIf (blnWaitForRecordSet =True And Not
ObjADORecordSet.EOF) Or (blnWaitForRecordSet = Fa
lse And ObjADORecordSet.EOF) Or blnWaitForRecordSe
t = "" Then
Set ObjRecordSet = ObjADORecordSet
gfGetDBRecordSet_Wait = True
blnFalg = True
Exit For
End If
Wait(1)
Set ObjADORecordSet = Nothing
Set objCon = Nothing
Next
If blnFalg = False Then
On Error GoTo 0
Call gfExitAction(strFuncName , "Unable to
execute the query :" & strQuery)
End If
Set objCon = Nothing
End Function
'#################################################
##################################################
41. ################
'# Function: gfUpLoadAttachmentToQC(ByVal strResult
FilePath)
'# Function is used to upload attachement to QC
'#
'# Parameters:
'# Input Parameters:
'# strResultFilePath - Path of the file to upload t
o QC
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Returns True/False
'#
'# Usage:
'# The usage of this Procedure is
'# strStatus = gfUpLoadAttachmentToQC(strResultFile
Path)
'#################################################
##################################################
##################
'Private Sub lfUpLoadAttachmentToQC(ByVal strResult
FilePath)
'
' Err.Clear
'
' Dim objAttachmentFactory,ObjAttachItem
' Dim strFuncName 'Procedure Name is stored for d
isplaying the Fail error message details
'
' strFuncName = "Error in gfUpLoadAttachmentToQC(
):"
'
' 'Upload Attachment to Quality Center
' Set objAttachmentFactory = QCUtil.CurrentTestSe
tTest.Attachments
' Set ObjAttachItem = objAttachmentFactory.AddIte
m(Null)
' ObjAttachItem.FileName = strResultFilePath
' ObjAttachItem.Type = 1
' ObjAttachItem.Post
42. ' ObjAttachItem.Refresh
'
' Set objAttachmentFactory = Nothing
' Set ObjAttachItem = Nothing
'
' If(Err.Number<>0) Then
' Err.Clear
' End If
'End Sub
'
'''###############################################
##################################################
##################
''# Function: gfGetWeekdayDate(ByRef strDate)
''# Function is used to get the next available wor
king day date if the delivery date falls under wee
kend
''#
''# Parameters:
''# Input Parameters:
''# strDate - Date falls under weekend
''#
''# Remarks:
''# Returns next available working day date
''#
''# Usage:
''# The usage of this Procedure is
''# > strResult = gfGetWeekdayDate(strDate)
''################################################
##################################################
###################
'Public Function gfGetWeekdayDate(ByRef strDate)
' Dim dtThanksgiving
'
' 'Validating for Thanks giving day and fetching
last thursday of November
' If Month(strDate)=11 Then
' dtThanksgiving=DateAdd("d",-1,Cdate(Cstr(M
onth(strDate)+1)&"/01/"&Year(strDate)))
' For intLoop = 30 To 20 Step -1
' If Weekday(dtThanksgiving)=5 Then Exit
For
43. ' dtThanksgiving=DateAdd("d",-1,dtThanksg
iving)
' Next
' End If
' 'Validating for Thanks giving day and christmas
and adding a day to Estimated date
' 'if the estimated date falls on thanks giving o
r Christmas
' If DateDiff("d",dtThanksgiving,strDate)=0 Or
(Day(strDate)=25 And Month(strDate)=12) Then
' strDate=DateAdd("d", 1,strDate)
' End If
' 'Vaildating and adding days to estimated date i
f it falls on saturday or Sunday
' If WeekDayName(WeekDay(strDate)) = "Saturday" T
hen
' strDate = DateAdd("d", 2,strDate)
' ElseIf WeekDayName(WeekDay(strDate)) = "Sunday"
Then
' strDate = DateAdd("d", 1,strDate)
' End If
'End Function
'#################################################
##################################################
################
'# Function: gfCloseApplication(ByVal strApplicatio
nExeName)
'# Function is used to Kill the Exceed Application
'#
'# Parameters:
'# Input Parameters:
'# strApplicationExeName - Name of the Applicatio
n
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# None
'#
'# Usage:
'# The usage of this procedure is
44. '# > Call gfCloseApplication("hostex32.exe")
'#################################################
##################################################
################
Public Function gfCloseApplication(ByVal strApplica
tionExeName)
Dim strComputer
Dim objWMIService
Dim colProcesses
Dim objProcess
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & s
trComputer & "rootcimv2")
Set colProcesses = objWMIService.ExecQuery ("S
elect * from Win32_Process Where Name = '" & strAp
plicationExeName & "'")
For Each objProcess In colProcesses
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set colProcesses = Nothing
End Function
'#################################################
##################################################
################
'# Function: lpDeleteFolders()
'# Procuder is used to Delete temperoroy folders
'#
'# Parameters:
'# Input Parameters:None
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# None
'#
'# Usage:
'# The usage of this procedure is
'# > Call lpDeleteFolders()
'#################################################
45. ##################################################
################
Private Sub lpDeleteFolders()
Dim objFSO
Dim strTempPath
Dim objFolder
Dim strPath
On Error Resume Next
Set objFSO= CreateObject("Scripting.FileSystemO
bject")
strTempPath=Environment.Value("SystemTempDir")
Set objFolder = objFSO.GetFolder(strTempPath)
For Each objFolder In objFolder.SubFolders
' Note : Only use *lowercase* letters in th
e folder names below:
If Instr(UCase(objFolder.Name),Ucase("Tempo
rary Directory 1"))>0 Then
strPath=objFolder.Path
objFSO.DeleteFolder strPath,True
End If
Next
On Error goto 0
End Sub
'#################################################
##################################################
################
'# Procedure : lpCloseAllDialogs
'# Closes all the Dialogs
'#
'# Parameters:
'# Input Parameters : N/A
'# Output Parameters: N/A
'#
'# Usage:
'# usage of this procedure is
'# > call lpCloseAllDialogs()
'#################################################
##################################################
################
Private Sub lpCloseAllDialogs()
Dim numDialogElems
46. Dim DialogElements
Dim oDesc
Dim inti
' Reporter.Filter = 3
Set oDesc = Description.Create()
oDesc("micclass").Value = "Dialog"
Set DialogElements = Desktop.ChildObjects(oDesc
)
For inti = 0 to DialogElements.Count - 1
If DialogElements(inti).GetROProperty("ena
bled") = True and Len(Trim(DialogElements(inti).Ge
tROProperty("text")))>0 Then
On Error Resume Next
DialogElements(inti).Close
Wait(1)
End If
Next
Err.Clear
' Reporter.Filter = 0
End Sub
'#################################################
##################################################
################
'# Function: gfGetScriptVariablesData(ByVal strExc
elFilePath,ByVal strScriptName,ByRef ObjADORecordS
et)
'# This Procedure retrieves the test data for a sp
ecific test script from Test Data location
'#
'# Parameters:
'# strExcelFilePath - Excel file path
'# strScriptName - Name of the script
'#
'# OutPut Parameters:
'# N/A
'#
'# Function Return Value:
'# True/False indicating the Successful execution o
f the Procedure.
'#
47. '# True-Successful, False-Unsuccessful
'#
'# Remarks:
'# Script Name is not Mandatory you can send empty
"" as parameter and the Procedure will take the C
urrent Script Name by Default
'#
'# Usage:
'# Below is the example to search and add asset in
'Browse' tab
'#
'# Call gfGetScriptVariablesData("........Test
DataSampleTestData.xls",Trim(Left(Environment.Va
lue("ActionName"),Len(Environment.Value("ActionNam
e"))-Instr(1,Environment.Value("ActionName"),"["))
),objRs)
'# strProjectDescription = objRs.Item("strProjectDe
scription")
'# strDefaultDisplayName = objRs.Item("strDefaultDi
splayName")
'#################################################
##################################################
################
Public Function gfGetScriptVariablesData(ByVal str
ExcelFilePath,ByVal strScriptName,ByRef ObjADOReco
rdSet)
Dim objRsAct 'Record set object
Dim intCounter 'Loop counter
Dim intColCnt 'Stores Column Coun
t
Dim intCurrColCnt 'Stores Current Col
Count
Dim strFuncName 'Stores Procedure N
ame
Dim arrTempContent 'Array to store Mod
ule Name
strFuncName = "Error in gfGetScriptVariablesDat
a():"
Set ObjADORecordSet=CreateObject("ADODB.records
48. et")
arrTempContent=Split(strScriptName,"_")
If Len(Trim(strScriptName)) = 0 Then
strScriptName = Trim(Left(Environment.Valu
e("ActionName"),Len(Environment.Value("ActionName"
))-Instr(1,Environment.Value("ActionName"),"[")))
End If
Call gfGetExcelRecordSet(strExcelFilePath,arrT
empContent(1),"TestScriptName='" & strScriptName &
"'",objRSAct,True)
Set ObjADORecordSet = CreateObject("ADODB.Recor
dset")
intCounter = 0
intColCnt = 0
Do while Not objRSAct.EOF
If intCounter = 0 Then 'Reading the First
Row and preparing RecordSet Fields
For intColCnt = 1 To objRSAct.Fields.Co
unt-1
If Trim(objRSAct.Fields(intColCnt).
value & "") = "" Then
ObjADORecordSet.Open
Exit For
End If
ObjADORecordSet.Fields.Append Trim
(objRSAct.Fields(intColCnt).value & ""), adVarChar
, 2000
Next
Else
'Adding Data To The Record Set
ObjADORecordSet.AddNew
For intCurrColCnt = 0 To intColCnt-2
ObjADORecordSet.Fields(intCurrColC
nt).Value = Trim(objRSAct.Fields(intCurrColCnt+1).
Value & "")
Next
End If
If Err.Number<>0 Then
On Error GoTo 0
Call gfExitAction(strFuncName , "Unabl
49. e to Create Reporting Folder Structure")
Exit Do
End If
intCounter = intCounter + 1
objRSAct.MoveNext
Loop
If Not ObjADORecordSet.EOF Then
ObjADORecordSet.MoveFirst
End If
Set objRSAct = Nothing
End Function
'#################################################
##################################################
################
'# Function: gfObjectExists(ByRef objControl)
'# Function used to verify whether required object
is exists or not
'#
'# Parameters:
'# Input Parameters:
'# objControl - Object to be verified
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Verifies the Object existence, If objControl pa
rameter is empty then reports the failure mesage w
ith appropriate message
'# Waits for the Object until elapsed time is great
er than gTIMEOUT = 60 Sec
'#
'# Usage:
'# The usage of this function is
'# strStatus = gfObjectExists(Browser("brSOSDesign
Tools").Page("pgProductPage").WebElement("weDirect
Search"))
'#################################################
##################################################
##################
Public Function gfObjectExists(ByRef objControl)
50. Err.Clear
Dim objExistenceTimer
Dim strFuncName 'Function Name while displaying
the Fail error message details
strFuncName = "Error in gfObjectExists():"
gfObjectExists = False
'Re-identify the object in the application the
next time a step refers to this object
'objControl.RefreshObject
'check whether objControl is Empty or not
If(IsEmpty(objControl)) Then
gfReportExecutionStatus micFail,strFuncName
,"Object is Empty"
Exit Function
ElseIf objControl Is Nothing Then
gfReportExecutionStatus micFail,strFuncName
,"Object is not found"
Exit Function
'check whether objControl is Object or not
ElseIf(Not(IsObject(objControl)))Then
gfReportExecutionStatus micFail,strFuncName
,"In Parameter is not an object"
Exit Function
End If
'Call gfSyncApplication(objControl.GetROPropert
y("micClass"))
'check whether object objControl is exists or n
ot
Set objExistenceTimer = MercuryTimers.Timer("Ob
jectExists")
objExistenceTimer.Start
Do
If(objControl.Exist(gSHORTWAIT)) Then
gfObjectExists = True
If(Not((objControl.GetROProperty("micC
lass")="WinEdit") OR (objControl.GetROProperty("mi
51. cClass")="WinButton") Or (objControl.GetROProperty
("micClass")="Dialog")Or (objControl.GetROProperty
("micClass")="WinListView")Or (objControl.GetROPro
perty("micClass")="Window")Or gfRegExpExecute("Te*
",True, objControl.GetROProperty("micClass")))) Then
objControl.MakeObjVisible()
End If
Exit Do
End If
Wait CInt(gDELAYINTERVAL)
Loop Until ((objExistenceTimer.ElapsedTime)/100
0) > CInt(gTIMEOUT)
objExistenceTimer.Stop
Set objExistenceTimer=Nothing
'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Function
'#################################################
##################################################
################
'# Function: gfIsEnabled(ByVal objControl)
'# Function used to check objectControl is Enabled
or Not
'#
'# Parameters:
'# Input Parameters:
'# objControl - Object on which action to be perfor
med
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
52. '# Verifies whether the object is enabled returns T
rue if exist else false
'#
'# Usage:
'# The usage of this function is
'# blnStatus = gfIsEnabled(Browser("brSOSDesignToo
ls").Page("pgProductPage").Webbutton("btnSearch"))
'#################################################
##################################################
################
Public Function gfIsEnabled(ByVal objControl)
Err.Clear
Dim strFuncName 'Function Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in gfIsEnabled():"
'Re-identify the object in the application the
next time a step refers to this object
'objControl.RefreshObject
gfIsEnabled = False
If (objControl.GetROProperty("disabled") = 0) T
hen
gfIsEnabled = True
End If
'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Function
'#################################################
##################################################
53. ################
'# Function: lfToString(ByRef objControl)
'# Function used to display ObjectName
'#
'# Parameters:
'# Input Parameters:
'# objControl - Action to be performed
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'#
'# Usage:
'# The usage of this function is
'# > Call lfToString(objControl)
'#################################################
##################################################
##################
Private Function lfToString(ByRef objControl)
Err.Clear
Dim strFuncName 'Function Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in lfToString():"
Dim Properties,intPropertiesCount,arrProperties
(),i
If objControl Is Nothing Then
Exit Function
End If
'If Dp is used then retrive all property names
and values
If(Trim(Split(objControl.ToString," ")(0))="[")
Then
Set Properties = objControl.GetTOProperties
intPropertiesCount = Properties.Count
ReDim arrProperties(intPropertiesCount - 1
)
For i = 0 To intPropertiesCount - 1
arrProperties(i)=Properties(i).Name & "
54. :" & Properties(i).Value
Next
lfToString = Join(arrProperties,",")
Else
'If Object is in OR
lfToString = Trim(objControl.GetTOProperty(
"TestObjName"))
End If
'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
FuncName & Err.Description & Chr(34) )
Err.Clear
End If
End Function
'#################################################
##################################################
##################
'# Function: gfGetRelativePath(ByVal strUploadedFil
eName)
'# Function used to Get actual path from the relati
ve path of QTP
'#
'# Parameters:
'# Input Parameters:
'# strUploadedFileName - QTP Relative path as strin
g
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Returns string with the actual path from the fun
ction
'#
'# Usage:
'# The usage of this function is
'# strActPath = f_GetRelativePath(strRelPath)
'#################################################
##################################################
55. ##################
Public Function gfGetRelativePath(ByVal strUploaded
FileName)
Dim strTemp
gfGetRelativePath = ""
If InStr(strUploadedFileName, "..") = 0 Then
gfGetRelativePath = strUploadedFileName
Exit Function
End If
If Len(Trim(strUploadedFileName)) =0 Then
Exit Function
End If
If PathFinder.Locate(strUploadedFileName) = ""
Then
strUploadedFileName = ".." & strUploadedFi
leName
End If
strUploadedFileName = PathFinder.Locate(strUplo
adedFileName)
If InStr(strUploadedFileName, "") > 0 Then
strTemp = Replace(Mid(strUploadedFileName,3
), "", "")
If Left(strUploadedFileName,2) = "" Then
strUploadedFileName = "" & strTem
p
End If
End If
gfGetRelativePath = strUploadedFileName
End Function
'#################################################
##################################################
##################
'# Function: gfDBExecuteSQLQuery(ByVal strConnectio
nString, ByVal strQuery)
'# Function used to Execute SQL statement against
database if Zero records are affected it will retu
rn False else True
'#
'# Parameters:
56. '# Input Parameters:
'# strConnectionString - Connection String object
'# strQuery - valid select query
'#
'# OutPut Parameters: N/A
'#
'# Remarks:
'# Verifies database for mentioned select query
'#
'# Usage:
'# The usage of this function is
'# intResult = gfDBExecuteSQLQuery("Delete From [Ta
ble-name] Where [where condition]")
'#################################################
##################################################
##################
Public Function gfDBExecuteSQLQuery(ByVal strConnec
tionString, ByVal strQuery)
Err.Clear
'Variable Declarations
Dim objCon
Dim intRecordsAffected
Dim strFuncName 'Function Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in gfDBExecuteSQLQuery():"
On Error Resume Next
'Variable assignments
gfDBExecuteSQLQuery = False
Set objCon= CreateObject("ADODB.Connection")
'Decrypt Password and rebuild connection string
strConnectionString=gfBuildConnectionstring(str
ConnectionString)
objCon.ConnectionString = strConnectionString
objCon.Open
objCon.CommandTimeout = 3000
intRecordsAffected = 0
objCon.Execute strQuery,intRecordsAffected
57. If Err.Number <> 0 Then
On Error GoTo 0
Call gfExitAction(strFuncName , "Unable to
execute the query :" & strQuery)
End If
If intRecordsAffected > 0 Then
gfDBExecuteSQLQuery=True
End If
Set Conn = Nothing
End Function
'#################################################
##################################################
################
'# Function: gfGetTestScriptPath(ByVal strRelativeP
ath)
'# Function is used to get the path of the TestScri
pt
'#
'# Parameters:
'# Input Parameters:
'# strRelativePath - Upto which level Path to be re
trieved
'#
'# Remarks:
'# Returns TestScript Path
'#
'# Usage:
'# The usage of this function is
'# > strScriptPath = gfGetTestScriptPath("....")
'#################################################
##################################################
##################
Public Function gfGetTestScriptPath(ByVal strRelati
vePath)
Dim qtpApp '
Dim arrPath
Dim strPath
Dim intCnt
Dim strFuncName 'Function Name is stored for d
isplaying the Fail error message details
58. strFuncName = "Error in gfGetTestScriptPath():"
'Create the Quicktest object
Set qtpApp = CreateObject("QuickTest.Applicatio
n")
'Retrieve the Path of the test
strPath = qtpApp.Test.Location
'Reduce the number of levels in the path based
on the parameter
If Len(Trim(strRelativePath))>0 Then
arrPath = Split(strPath, "")
strPath = ""
For intCnt =0 To UBound(arrPath)-UBound(Spl
it(strRelativePath,""))
strPath = strPath & arrPath(intCnt) & "
"
Next
End If
gfGetTestScriptPath= strPath
End Function
'#################################################
##################################################
################
'# Function: gfNumberFormat(ByVal intNumber,ByVal s
trFormat)
'# Function is used to get the number formatted as
required
'#
'# Parameters:
'# Input Parameters:
'# strRelativePath - Upto which level Path to be re
trieved
'#
'# Remarks:
'# Returns String in the required format
'#
'# Usage:
'# The usage of this function is
'# strDay = gfNumberFormat(Day(Date),"0000")
'#################################################
##################################################
59. ##################
Public Function gfNumberFormat(ByVal intNumber,ByVa
l strFormat)
Dim strTemp 'Number Formatting
strTemp = CStr(intNumber)
If Len(strTemp) >= Len(strFormat) Then
gfNumberFormat = strTemp
Else
gfNumberFormat = Left(strFormat, Len(strFor
mat)-Len(strTemp)) & strTemp
End If
End Function
'#################################################
##################################################
################
'# Function: gfRegExpExecute(ByVal sPatrn, ByVal bI
gnoreCase, ByVal sString)
'# Function is used to find a regular expression p
attern string in a string which will compare the s
tring and returns True/False if the match is found
with the regular expression pattern
'#
'# Parameters:
'# Input Parameters:
'# sPatrn - String Pattern to be verified
'# bIgnoreCase - Boolean True/False to Ignore strin
g case while verifying
'# sString - String to be verified in
'# Output Parameters: N/A
'#
'# Remarks:
'# For more details on the regular expressions go t
hrough the help document
'#
'# Usage:
'# Below example verifies 'abc100' in the string i
t is compared with a regular expression pattern [a
-z0-9A-Z]+ is a regular expression pattern which w
ill compare with the string and returns true in th
e below case
60. '# blnStatus = gfRegExpExecute("Select This [a-z0-
9A-Z]+% abc",True,"Select This abc100% abc")
'#################################################
##################################################
##################
Public Function gfRegExpExecute(ByVal sPatrn, ByVal
bIgnoreCase, ByVal sString)
Dim oRegEx ' Create variable.
Dim oMatches
gfRegExpExecute = False
Set oRegEx = New RegExp ' Create regular expres
sion.
oRegEx.Pattern = sPatrn ' Set pattern.
oRegEx.IgnoreCase = bIgnoreCase ' Set case inse
nsitivity.
oRegEx.Global = True ' Set global applicability
.
Set oMatches = oRegEx.Execute(sString) ' Execut
e search.
If oMatches.Count>0 Then
gfRegExpExecute = True
End If
End Function
'#################################################
##################################################
##################
'# Function: gfGetROProperty(ByRef objControl,ByVal
strPropertyName)
'# This Function is used to Get the ROProperty of g
iven ObjectControl
'#
'# Parameters:
'# Input Parameters:
'# objControl - Object on which action to be perfor
med
'# strPropertyName - Property Name of ObjControl
'# OutPut Parameters: N/A
'#
'# Remarks:
'# This Function is used to Get the ROProperty
'#
61. '# Usage:
'# The usage of this function is
'# strProprtyVal = gfGetROProperty(Browser("brSOSD
esignTools").Page("pgProductPage").WebList("lstSea
rchBy"),"title")
'#################################################
##################################################
##################
Public Function gfGetROProperty(ByRef objControl,By
Val strPropertyName)
Err.Clear
Dim strTestObjectName
Dim strFuncName
gfGetROProperty = ""
strFuncName = "Error in gfGetROProperty():"
gfGetROProperty=""
strTestObjectName = lfToString(objControl)
'check whether object objControl is exists or n
ot
If (gfObjectExists(objControl)) Then
gfReportExecutionStatus micDone, strFuncNa
me,"Object [" & strTestObjectName & "] is Exists"
'Get the RO Property of given object contro
l
gfGetROProperty = Trim(objControl.GetROProp
erty(strPropertyName))
Else
'If objControl is not found then Exit from
current Action
On Error GoTo 0
Call gfExitAction(strFuncName , "Object ["
& strTestObjectName & "] dose not Exist")
End If
'Check and Report Runtime Errors If any
If (Err.Number<>0) Then
Call gfReportExecutionStatus(micFail,strFu
ncName,"Run Time Error Details : " & Chr(34) & str
62. FuncName & Err.Description & Chr(34))
Err.Clear
End If
End Function
'#################################################
##################################################
################
'# Function: gfEncryptString(ByVal strPassword)
'# Function is used to encrypt the given string and
copy the encrypted sting to clipboard
'#
'# Parameters:
'# Input Parameters:
'# strPassword - Password to Encrypt
'# OutPut Parameters:
'# Returns the encrypterd string
'# Remarks:
'# Use this function to encrypt the password
'#
'# Usage:
'#
'# Call gfEncryptString("Password")
'#################################################
##################################################
################
Public Function gfEncryptString(ByVal strPassword)
Dim strChar
Dim intLoop
Dim strtmp
Dim objClipboard
For intLoop = 1 To Len( strPassword)
strChar = Mid( strPassword, intLoop, 1 )
strtmp = strtmp & Chr( Asc( strChar ) + Env
ironment.Value("SeedValue") )
Next
Set objClipboard=CreateObject("Mercury.Clipboar
d")
objClipboard.Clear
63. objClipboard.SetText Replace(StrReverse( strtmp
), "&",Environment.Value("MaskValue"))
Msgbox "The Encrypted password has been copied
to clipboard"
End Function
'#################################################
##################################################
################
'# Function: gfDecryptString(ByVal strPassword)
'# Function is used to Decrypt the encrypted string
using gfEncryptString function
'#
'# Parameters:
'# Input Parameters:
'# strPassword - Password to Decrypt
'# OutPut Parameters:
'# Returns the decrypted string
'# Remarks:
'#
'#
'# Usage:
'#
'# Call gfDecryptString("Password")
'#################################################
##################################################
################
Public Function gfDecryptString(ByVal strPassword)
Dim strChar
Dim intLoop
Dim strtmp
strPassword = Replace(strPassword,Environment.V
alue("MaskValue"),"&")
For intLoop = 1 To Len( strPassword)
strChar = Mid( strPassword, intLoop, 1 )
strtmp= strtmp & Chr( Asc( strChar) - Envir
onment.Value("SeedValue"))
Next
gfDecryptString= StrReverse( strtmp)
End Function
'#################################################
64. ##################################################
################
'# Function: gfBuildConnectionstring(ByRef strConne
ctionString)
'# Function is used to build the connection string
with Decrypted password
'#
'# Parameters:
'# Input Parameters:
'# strPassword - Password to Decrypt
'# OutPut Parameters:
'# Returns the decrypted string
'# Remarks:
'#
'# Usage:
'# Call gfDecryptString("Password")
'#################################################
##################################################
################
Public Function gfBuildConnectionstring(ByRef strCo
nnectionString)
Dim arrPart
arrPart=Split(Split(strConnectionString,"PWD=")
(1),";")
arrPart(0)=gfDecryptString(arrPart(0))
strConnectionString=Split(strConnectionString,
"PWD=")(0)& "PWD="& Replace(Join(arrPart)," ",";")
gfBuildConnectionstring=strConnectionString
End Function
'#################################################
##################################################
################
'# Function: gfFormatDate(ByVal strDateTime, ByVal
strFormat)
'# Converts date as per the specified format
'#
'# Parameters:
'# strDateTime - Date Time string
'# strFormat - Format to which the date time need t
o be converted
'#
65. '# Function Return Value:
'# Returns the date converted to specified format.
'#
'# Remarks:
'# -NA-
'#
'# Usage:
'# Below is the example to retrieve DateTime covert
ed to a specific format
'#
'# strNewDate = gf_date (now(), "yyyy-mm-dd")
'#
'# strNewDate = gf_date (time(), "hh:mm")
'#
'#################################################
##################################################
################
Public Function gfFormatDate(ByVal strDateTime, ByV
al strFormat)
Dim objFmt 'StdDataFormat object
Dim ObjADORecordSet 'Resultset object
Dim strFuncName 'Function Name is stored for d
isplaying the Fail error message details
strFuncName = "Error in gfFormatDate():"
On Error Resume Next
set objFmt = CreateObject("MSSTDFMT.StdDataForm
at")
objFmt.Format = strFormat
set ObjADORecordSet = CreateObject("ADODB.Recor
dset")
ObjADORecordSet.Fields.Append "fldExpression",
12
ObjADORecordSet.Open
ObjADORecordSet.AddNew
set ObjADORecordSet("fldExpression").DataFormat
= objFmt
ObjADORecordSet("fldExpression").Value = strDat
66. eTime
gfFormatDate = ObjADORecordSet("fldExpression")
.Value
ObjADORecordSet.close
Set ObjADORecordSet = Nothing
Set objFmt = Nothing
If Err.Number <> 0 Then
On Error GoTo 0
Call gfExitAction(strFuncName , "Unable to
format the provided date:" & strDateTime & " Erro
r:" & Err.Description)
End If
End Function
'#################################################
##################################################
################
'# Function: gfSyncApplication(ByVal strmicClassNam
e)
'# Sync's the application based on the object sent
'#
'# Parameters:
'# Input Parameters:
'# strmicClassName - Object MicClass should be sent
'#
'# Remarks:
'# -NA-
'#
'# Usage:
'# Below is the example to Sync the application
'# Call gfSyncApplication(objControl.GetROProperty(
"micClass"))
'#################################################
##################################################
################
Public Function gfSyncApplication(ByVal strmicClass
Name)
67. Select Case strmicClassName
'Web Application Sync
Case "WebButton","Link","Image","WebElemen
t","WebRadioGroup","WinButton","WebCheckBox"
Call gfBrowserSync()
'Case :To-Do For TE,SAP etc., Application
End Select
End Function