Friday, July 6, 2007

User defined Result file

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' About : Delcaration of Constans and Variables
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public g_sFileName 'Report Log File Name.
Public g_iCapture_Count 'Number of Images captured
Public g_iImage_Capture 'Flag for Image Capture in Result File
Public g_iPass_Count 'Pass Count
Public g_iFail_Count 'Fail Count
Public g_tStart_Time 'Start Time
Public g_tEnd_Time 'End Time

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' About : Procedure to Open a HTML File for Report Log
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Public Sub rep_Open_File(sFileName, iImageCapture)
Dim g_objReport 'File Object
Dim g_objFS 'File System Object

g_iPass_Count = 0
g_iFail_Count = 0
g_sFileName = sFileName
g_iImage_Capture = iImageCapture
Set g_objFS = CreateObject("Scripting.FileSystemObject")
Set g_objReport = g_objFS.OpenTextFile(g_sFileName, 2, True)
g_objReport.Write "<$$HTML><$$BODY><$$TABLE BORDER=0 CELLPADDING=3 CELLSPACING=1 WIDTH=100%>"
g_objReport.Write "<$$TR COLS=2><$$TD BGCOLOR=WHITE WIDTH=6%><$$IMG SRC='https://webaccess.kdc.capitalone.com/GetAccess/images/logo_sso.gif'><$/$TD><$$TD WIDTH=94% BGCOLOR=WHITE><$FONT FACE=VERDANA COLOR=NAVY SIZE=2><$$B> Helix ProphIT Automation - " & Date & " - " & Time & " on Machine " & Environment.Value("LocalHostName") & "<$$/B><$$/FONT><$$/TD><$$/TR><$$/TABLE>"
g_objReport.Write "<$$TABLE BORDER=0 BGCOLOR=BLACK CELLPADDING=3 CELLSPACING=1 WIDTH=100%>"
g_objReport.Close
Set g_objFS = Nothing
Set g_objReport = Nothing
g_tStart_Time = Now()
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' About : Procedure to Insert a Section to Report Log
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Public Sub rep_Insert_Section(sSection)
Dim g_objReport 'File Object
Dim g_objFS 'File System Object
Set g_objFS = CreateObject("Scripting.FileSystemObject")
Set g_objReport = g_objFS.OpenTextFile(g_sFileName, 8, True)
g_objReport.Write "<$$TR><$$TD COLSPAN=6 BGCOLOR=#66699><$$FONT FACE=VERDANA COLOR=WHITE SIZE=2><$$B>" & sSection & "<$$/B><$$/FONT><$$/TD><$$/TR>"
g_objReport.Write "<$$TR COLS=6><$$TD BGCOLOR=#FFCC99 WIDTH=25%><$$FONT FACE=VERDANA COLOR=BLACK SIZE=2><$$B>Description<$$/B><$$/FONT><$$/TD><$$TD BGCOLOR=#FFCC99 WIDTH=25%><$$FONT FACE=VERDANA COLOR=BLACK SIZE=2><$$B>Expected Result<$$/B><$$/FONT><$$/TD><$$TD BGCOLOR=#FFCC99 WIDTH=25%><$$FONT FACE=VERDANA COLOR=BLACK SIZE=2><$$B>Actual Result<$$/B><$$/FONT><$$/TD><$$TD BGCOLOR=#FFCC99 WIDTH=25%><$$FONT FACE=VERDANA COLOR=BLACK SIZE=2><$$B>Result<$$/B><$$/FONT><$$/TD><$$TD BGCOLOR=#FFCC99 WIDTH=7%><$$FONT FACE=VERDANA COLOR=BLACK SIZE=2><$$B>Test Type<$$/B><$$/FONT><$$/TD><$$/TR>"
g_objReport.Close
Set g_objFS = Nothing
Set g_objReport = Nothing
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' About : Procedure to Insert a Step to Report Log
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Public Sub rep_Insert_Step(sDesc)
Dim g_objReport 'File Object
Dim g_objFS 'File System Object
Set g_objFS = CreateObject("Scripting.FileSystemObject")
Set g_objReport = g_objFS.OpenTextFile(g_sFileName, 8, True)
g_objReport.Write "<$$TR><$$TD BGCOLOR=#EEEEEE COLSPAN=5><$$FONT FACE=VERDANA SIZE=2><$$B>" & sDesc & "<$$/B><$$/FONT><$$/TD><$$/TR>"
g_objReport.Close
Set g_objFS = Nothing
Set g_objReport = Nothing
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' About : Procedure to Insert a Result to Report Log
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Public Sub rep_Insert_Result(sDesc, sExpected, sActual, sResult, sTestType)
Dim g_objReport 'File Object
Dim g_objFS 'File System Object
Dim l_sFile 'Bitmap File Name

Set g_objFS = CreateObject("Scripting.FileSystemObject")
Set g_objReport = g_objFS.OpenTextFile(g_sFileName, 8, True)

If sResult="PASS" Then
g_iPass_Count = g_iPass_Count + 1
If g_iImage_Capture=2 Then
l_sFile = Environment("ResultDir") & "\Screen" & g_iCapture_Count & ".png"
Desktop.CaptureBitmap l_sFile
g_iCapture_Count = g_iCapture_Count + 1
g_objReport.Write "<$$TR COLS=5><$TD BGCOLOR=#EEEEEE WIDTH=25%><$$FONT FACE=VERDANA SIZE=2>" & sDesc & "<$$/FONT><$$/TD><$$TD BGCOLOR=#EEEEEE WIDTH=25%><$$FONT FACE=VERDANA SIZE=2>" & sExpected & "<$$/FONT><$$/TD><$$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=WINGDINGS SIZE=4>2<$/FONT><$FONT FACE=VERDANA SIZE=2><$A HREF='" & l_sFile & "'>" & sActual & "<$/A><$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=7%><$FONT FACE='WINGDINGS 2' SIZE=5 COLOR=GREEN>P<$/FONT><$FONT FACE=VERDANA SIZE=2 COLOR=GREEN><$B>" & sResult & "<$/B><$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=18%><$FONT FACE=VERDANA SIZE=2>" & sTestType & "<$/FONT><$/TD><$/TR>"
Reporter.ReportEvent micPass,sDesc,sActual
Else
g_objReport.Write "<$TR COLS=5><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sDesc & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sExpected & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sActual & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=7%><$FONT FACE='WINGDINGS 2' SIZE=5 COLOR=GREEN>P<$/FONT><$FONT FACE=VERDANA SIZE=2 COLOR=GREEN><$B>" & sResult & "<$/B><$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=18%><$FONT FACE=VERDANA SIZE=2>" & sTestType & "<$/FONT><$/TD><$/TR>"
Reporter.ReportEvent micPass,sDesc,sActual
End If
ElseIf sResult="FAIL" Then
g_iFail_Count = g_iFail_Count + 1
If g_iImage_Capture=1 Or g_iImage_Capture=2 Then
l_sFile = Environment("ResultDir") & "\Screen" & g_iCapture_Count & ".png"
Desktop.CaptureBitmap l_sFile
g_iCapture_Count = g_iCapture_Count + 1
g_objReport.Write "<$TR COLS=5><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sDesc & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sExpected & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=WINGDINGS SIZE=4>2<$/FONT><$FONT FACE=VERDANA SIZE=2><$A HREF='" & l_sFile & "'>" & sActual & "<$/A><$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=7%><$FONT FACE='WINGDINGS 2' SIZE=5 COLOR=RED>O<$/FONT><$FONT FACE=VERDANA SIZE=2 COLOR=RED><$B>" & sResult & "<$/B><$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=18%><$FONT FACE=VERDANA SIZE=2>" & sTestType & "<$/FONT><$/TD><$/TR>"
Reporter.ReportEvent micFail,sDesc,sActual
Else
g_objReport.Write "<$TR COLS=5><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sDesc & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sExpected & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sActual & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=7%><$FONT FACE='WINGDINGS 2' SIZE=5 COLOR=RED>O<$/FONT><$FONT FACE=VERDANA SIZE=2 COLOR=RED><$B>" & sResult & "<$/B><$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=18%><$FONT FACE=VERDANA SIZE=2>" & sTestType & "<$/FONT><$/TD><$/TR>"
Reporter.ReportEvent micFail,sDesc,sActual
End If
Else
g_objReport.Write "<$TR COLS=5><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sDesc & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sExpected & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=25%><$FONT FACE=VERDANA SIZE=2>" & sActual & "<$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=7%><$FONT FACE='WINGDINGS 2' SIZE=5 COLOR=RED>O<$/FONT><$FONT FACE=VERDANA SIZE=2 COLOR=BLACK><$B>" & sResult & "<$/B><$/FONT><$/TD><$TD BGCOLOR=#EEEEEE WIDTH=18%><$FONT FACE=VERDANA SIZE=2>" & sTestType & "<$/FONT><$/TD><$/TR>"
Reporter.ReportEvent micGeneral,sDesc,sActual
End If

g_objReport.Close
Set g_objFS = Nothing
Set g_objReport = Nothing
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' About : Procedure to Close Report Log
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Public Sub rep_Close
Dim g_objReport 'File Object
Dim g_objFS 'File System Object
Set g_objFS = CreateObject("Scripting.FileSystemObject")
Set g_objReport = g_objFS.OpenTextFile(g_sFileName, 8, True)
g_tEnd_Time = Now()
g_objReport.Write "<$TR COLS=5><$TD BGCOLOR=BLACK WIDTH=25%><$FONT FACE=VERDANA COLOR=WHITE SIZE=2><$B>Pass Count : " & g_iPass_Count & "<$/B><$/FONT><$/TD><$TD BGCOLOR=BLACK WIDTH=25%><$FONT FACE=VERDANA COLOR=WHITE SIZE=2><$B>Fail Count : " & g_iFail_Count & "<$/B><$/FONT><$/TD><$TD BGCOLOR=BLACK WIDTH=25%><$FONT FACE=VERDANA COLOR=WHITE SIZE=2><$B>Time Taken : " & DateDiff("n",g_tStart_Time,g_tEnd_Time) & " Minutes<$/B><$/FONT><$/TD><$TD BGCOLOR=BLACK WIDTH=7%><$FONT FACE=VERDANA COLOR=WHITE SIZE=2><$B><$/B><$/FONT><$/TD><$TD BGCOLOR=BLACK WIDTH=18%><$FONT FACE=VERDANA COLOR=WHITE SIZE=2><$B><$/B><$/FONT><$/TD><$/TR>"
g_objReport.Write "<$/TABLE><$/BODY><$/HTML>"
g_objReport.Close
Set g_objFS = Nothing
Set g_objReport = Nothing
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' About : Procedure to Show Report Log in Browser Window
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Public Sub rep_Show_Result
rep_Close
Set objIE = CreateObject("InternetExplorer.Application") ' Creating a new object for IE
objIE.Visible = True 'Setting the visible property to true
'msgbox g_sFileName & "#Summary"
objIE.Navigate g_sFileName & "#Summary"
End Sub

Synchronise Objects function

//Synchronise Objects function - another

Public Function fnSynchroniseObjects(objPage,objObjectToSynchronise,intWaitValue)

Dim blnResult

blnWaitProprtyValue=CBool(blnWaitProprtyValue)
intWaitValue=(Int(intWaitValue)*1000)
objPage.Sync

objObjectToSynchronise.WaitProperty "visible", True , intWaitValue

objObjectToSynchronise.WaitProperty "attribute/readyState", "complete", intWaitValue

End Function

verify the Heading text in a Frame

'' Name : fnVerifyHeadingText(objFrame, strHeading)
'' Description: This function is used to verify the Heading text in a Frame
'' Arguments :
'' objFrame: Frame object in which the heading is present
'' strHeading: Heading String
'' Return: True/False
'' Pre-Condition:The frame containing the heading should be displayed
'' Post-condition:
''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Public Function fnVerifyHeadingText(objFrame, strHeading)

Dim objDescWebElem, objWEHeading

fnVerifyHeadingText = True
'''''''''' Creating a web element object for Heading'''''''''''''
Set objDescWebElem = Description.Create()
objDescWebElem("micclass").Value = "WebElement"
objDescWebElem("innertext").Value = Trim(strHeading)
objDescWebElem("outertext").Value = Trim(strHeading)
objDescWebElem("html tag").Value="SPAN"

''''''''''Verify Heading''''''''''''''''''''''''''''''''
If objFrame.Exist(4) Then
Set objWEHeading = objFrame.ChildObjects(objDescWebElem)
If (objWEHeading.Count <= 0) Then
fnVerifyHeadingText = False
End If
Else
fnVerifyHeadingText = False
End If

End Function

verify the Items exists in Dropdown box

'' Name : fnVerifyDropDownItems(objDropdown, strItemsToSearch)
'' Description: This function is used to verify whether the Items exists in Dropdown box
'' Arguments :
''objDropdown: Dropdown box object in which the items are to be searched
''strItemsToSearch:Items that are to be searched separated by Comma (,)
''Example: "Domestic, Canada"
''Return: True/False
''Pre-Condition:The Dropdown box should be displayed
''Post-condition:
''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Public Function fnVerifyDropDownItems(objDropdown, strItemsToSearch)

Dim intItemsCount, intCounter, strItem, intItems, blnItemPresent
Dim arrItemsToSearch

fnVerifyDropDownItems=True

If (objDropdown.Exist = False) Then
reporter.report micFail,"The Dropdown box '" & objDropdown.GetROProperty("name") & "' should Exist", "The Dropdown Box does not exist", "FAIL")
fnVerifyDropDownItems=False
Exit Function
End If

'''''''' Get count of items in dropdown''''''''''''''''''

intItemsCount = objDropdown.GetTOProperty("items count")

''''''''Split the list items list based on comma(,)''''''

arrItemsToSearch = Split(strItemsToSearch, ",")

For intItems=0 to UBound(arrItemsToSearch)
blnItemPresent = False
''''''''''''Loop through all items''''''''''''''

For intCounter=1 to intItemsCount
strItem = ""
'''''''''' Get an item''''''''''''''''''

strItem = objDropdown.GetItem(intCounter)

'''''''''''''''If the search item is present'''''''''''''''''''''''

If (StrComp(Trim(strItem), Trim(arrItemsToSearch(intItems)), 1) = 0) Then
blnItemPresent = True
reporter.report micPass "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item exists in the dropdown box", "PASS")
Exit For
End If
Next
If (Not blnItemPresent) Then
reporter.report micFail , "The Item '" & arrItemsToSearch(intItems) & "' should be present in the dropdown box", "The specified Item does not exist in the dropdown box", "WARNING")
fnVerifyDropDownItems = False
End If
Next

End Function

Maximize the Browser

''Name : fnBrowserMaximize()
''Description: This function is used to Maximize the Browser
''Arguments:
''Example:
''Return True/False
'Pre-Condition: Chordiant Application
'Post-Condition:Chordiant Application
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Public Function fnBrowserMaximize()
fnBrowserMaximize=false

wait(2)
If Browser("Creationtime:=0").exist(1) then
If Browser("Creationtime:=0").Object.Top <> "-1" then

Browser("Creationtime:=0").Page("Creationtime:=0").sync
Browser("Creationtime:=0").FullScreen
fnBrowserMaximize=true
End If
End If
End Function

search for a Webobject in a webtable and to click the webobject

''Name : fnSearchAndClickTab(objTable,strSearchValue)
''Description: This function is used to search for a Webobject in a webtable and to click the webobject and returns true.If Webobject is not present then it return false.
''Arguments: : Web Table object
'' : webElement that needs to be clicking in the screen
''Example:
'' Set objTable=Browser("Capital One").Page("ProphIT - 7560 - COF -").Frame("WorkFlowFrame").WebTable("Workflow")
'' strSearchValue="Add Notes"
''Return true/False
'Pre-Condition: nil
'Post-Condition:nil
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

''Only for Tab order
Public Function fnSearchAndClickTab(objTable,strSearchValue)
fnSearchAndClickTab=False

Dim intRowCount
Dim intColumnCount
Dim strFromScreen
Dim objChild
Dim intRowLoop
Dim intColumnLoop
Dim intChildCount

Set objFrame=objTable
Set objPage=Browser("Chordiant").Page("Chordiant")
Call fnSynchroniseObjects(objPage,objFrame,20)
Browser("Chordiant").Page("Chordiant").sync

If isObject(objTable) and objTable.exist(0) Then' This will check for the object name

intRowCount = objTable.RowCount ' This will get the row count in that table
If not intRowCount=0 Then ' This will check whether the table is present or not

For intRowLoop =1 to intRowCount ' this navigates inside the table based on the row count

intColumnCount= objTable.ColumnCount(intRowLoop) ' this get the column count by giving the row number
For intColumnLoop = 1 to intColumnCount ' this navigates inside the table based on the column count
strFromScreen=objTable.GetCellData(intRowLoop,intColumnLoop) ' this get the value from the screen
If strcomp(trim(strFromScreen),trim(strSearchValue),1)=0 Then ' this compares the value from screen with value given

intChildCount=objTable.ChildItemCount( intRowLoop,int(intColumnLoop), "WebElement")' Verify for Webelement insite that table and gets count of it

If intChildCount<>0 Then
Set objChild=objTable.ChildItem (intRowLoop,int(intColumnLoop), "WebElement", 0)' Creates child element object
objChild.click ' selects the child element object
fnSearchAndClickTab=True
intRowLoop=intRowCount
intColumnLoop=intColumnCount
exit function
Else
Set objChild=objTable.ChildItem (intRowLoop,0, "WebElement", 0)' Creates child element object
objChild.click ' selects the child element object
fnSearchAndClickTab=True
intRowLoop=intRowCount
intColumnLoop=intColumnCount
exit function
End If

End If
Next
Next

End If
End If

Set objTable=nothing
End Function

search for WebElement value in Webtable and to click the webElement

''Name : fnSearchAndClick(objTable,strSearchValue)
''Description: This function is used to search for WebElement value in Webtable and to click the webElement and returns true.If WebElement is not present then it return false.
''Arguments: : Web Table object
'' : webElement that needs to be clicking in the screen
''Example:
'' Set objTable=Browser("Capital One").Page("ProphIT - 7560 - COF -").Frame("WorkFlowFrame").WebTable("Workflow")
'' strSearchValue="Add Notes"
''Return true/False
'Pre-Condition: Account Summary
'Post-Condition: Work Flow
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function fnSearchAndClick(objTable,strSearchValue)
On Error Resume Next
fnSearchAndClick=False

Dim intRowCount
Dim intColumnCount
Dim strFromScreen
Dim objChild
Dim intRowLoop
Dim intColumnLoop
Dim intChildCount

Set objFrame=objTable
Set objPage=Browser("Chordiant").Page("Chordiant")
Call fnSynchroniseObjects(objPage,objFrame,20)
Browser("Chordiant").Page("Chordiant").sync


If isObject(objTable) and objTable.exist(0) Then' This will check for the object name

intRowCount = objTable.RowCount ' This will get the row count in that table
If not intRowCount=0 Then ' This will check whether the table is present or not

For intRowLoop =1 to intRowCount ' this navigates inside the table based on the row count

intColumnCount= objTable.ColumnCount(intRowLoop) ' this get the column count by giving the row number
For intColumnLoop = 1 to intColumnCount ' this navigates inside the table based on the column count
strFromScreen=objTable.GetCellData(intRowLoop,intColumnLoop) ' this get the value from the screen
If strcomp(trim(strFromScreen),trim(strSearchValue),1)=0 Then ' this compares the value from screen with value given

intChildCount=objTable.ChildItemCount( intRowLoop,int(intColumnLoop-1), "WebElement")' Verify for Webelement insite that table and gets count of it

If intChildCount<>0 Then
Set objChild=objTable.ChildItem (intRowLoop,int(intColumnLoop-1), "WebElement", 0)' Creates child element object
objChild.click ' selects the child element object
fnSearchAndClick=True
intRowLoop=intRowCount
intColumnLoop=intColumnCount
exit function
Else
Set objChild=objTable.ChildItem (intRowLoop,0, "WebElement", 0)' Creates child element object
objChild.click ' selects the child element object
fnSearchAndClick=True
intRowLoop=intRowCount
intColumnLoop=intColumnCount
exit function
End If

End If
Next
Next

End If
End If
End Function

search for particular field in the table and to get the value in return

''Name : fnGetSearchData(objTable,intColumnCell,strSearchValue)
''Description: This function is used to search for particular field in the table and to get the value in return,
''for example on passing as "Primary:" it returns value like "abcd * efg", If that search value is not present
''then it returns "false" message
''Arguments: : Table object from where field name need to be searched
'' : columns cell away from the Searched string
'' : String need to be searched
''Example:
'' Set objTable=Browser("testing").Page("testing").Frame("WorkFlowFrame").WebTable("Primary:")
'' intColumnCell=1
'' strSearchValue="Primary:"
''Return Result Value/False
'Pre-Condition: NIL(Common)
'Post-Condition:NIL(Common)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public function fnGetSearchData(objTable,intColumnCell,strSearchValue)
On Error Resume Next
fnGetSearchData=false

'---------------Variable declaration-----------------------
Dim intRowCount
Dim intColumnCount
Dim strScreenValue
Dim intRowLoop
Dim intColLoop
'---------------Variable declaration-----------------------

Set objFrame=objTable
Set objPage=Browser("Chordiant").Page("Chordiant")
Call fnSynchroniseObjects(objPage,objFrame,20)
Browser("Chordiant").Page("Chordiant").sync


If IsObject(objTable) and objTable.Exist Then' Verify the Table object passed is an object and it exist or not
intRowCount=objTable.RowCount ' Gets the table row count

If not intRowCount ="" Then'Verify if the table row count is null or not

For intRowLoop=1 to intRowCount 'Loop navigates till row count ends

intColumnCount=objTable.ColumnCount(intRowLoop)' Get s the Table column count
For intColLoop =1 to intColumnCount' Loop navigates till column count ends

strScreenValue=objTable.GetCellData (intRowLoop,intColLoop)'Get the corresponding value from screen
If strcomp(trim(strScreenValue),trim(strSearchValue),1)=0 Then' compares the value from screen with value passed
intColumnCell=int(intColLoop+int(intColumnCell))
fnGetSearchData=objTable.GetCellData (intRowLoop,intColumnCell)' returns the value in function return value
Exit For ' After identifying the cell value it comes out of the loop
exit function
End If

Next

Next

End If
End If

End Function

Synchronize for a particular object

// function to Synchronize for a particular object

Public function fnSynchronization(objName)
fnSynchronization=false


Dim intLoopStart
Dim intLoopwait

intLoopStart=1
intLoopwait=10

Set objName=objName

'Waiting for the object to appear
Do while intLoopStart<=intLoopwait
'wait for exitance of that object
If objName.Exist(1) then

fnSynchronization=true
Exit do
Else
intLoopStart=intLoopStart+1
End if
Loop


End function

Get Record from database and display result

///this function is used to get the Record from the Database and display the result

Public Function fnGetRecord(strSQL,strConnectionString)
fnGetRecord=false

Dim dBRecSet,dBConnection

'Set the Database connection object
Set dBConnection=fnDBOpenConnection(strConnectionString)

'Verify for object exist or not
If isobject(dBConnection) Then

'Execute the SQL and get the recordset object
On error resume next
Set dBRecSet= dBConnection.execute(strSQL)

'Verify for the record set has reached EOF or not
If dBRecSet.EOF=false Then

blnResult=fnDisplayResult(dBRecSet,"dbo.fpac_acct_hedgeoverlay")

If blnResult Then
'return the recordset object back
'Set fnGetRecord=dBRecSet
fnGetRecord=true
End IF

'Check for the error number
If not err.number = 0 then
'fnInsertResult "Database Verification", "Verifying the Record from Database", "Error in either Table name or column name", "WARNING"
Reporter.ReportEvent micWarining, "Verifying the Record from Database", "Error in either Table name or column name"
fnGetRecord=false
Exit function
End If
On error goto 0

Else
'fnInsertResult "Database Verification", "Verifying the Record from Database", "No Record exist", "FAIL"
Reporter.ReportEvent micFail, "Verifying the Record from Database", "No Record Exist"

'Verify for the record set has reached EOF or not
End If
Else

fnGetRecord=false
'Verify for object exist or not
End If

'reinitialize the object to null
Set dBConnection=nothing
Set dBRecSet=nothing
End Function

''This function is used to display result from the record set object

Public function fnDisplayResult(dBRecSet,strTableName)
fnDisplayResult=false

Dim intLoop

If isobject(dBRecSet) Then
If dBRecSet.EOF = false Then
Do While Not dBRecSet.eof
For each intLoop in dBRecSet.fields

'fnInsertResult "Records form the database for Table Name"&strTableName, "Verifying the value for columns "&intLoop.name, " Value is : "&intLoop.value, "PASS"
Reporter.ReportEvent micPass, "Verifying the value for columns '"&intLoop.name&"' in Table '"&strTableName & "'", " Value is : '" &intLoop.value &"'"
fnDisplayResult=true
next
dBRecSet.MoveNext

Loop
Else
'fnInsertResult "Database Verification", "Verifying the Record from Database", "No Record exist", "FAIL"
Reporter.ReportEvent micFail, "Verifying the Record from Database", "No Record Exist"
End If
End If

Set dBRecSet = nothing
End Function

open Database connection

// Function to open Database connection

strConnectionString- DSN=dbFPAC;NA=dalton,3219;DB=fpac_int1;UID=wipajk;PWD=wipro9

Public Function fnDBOpenConnection(strConnectionString)
fnDBOpenConnection=false

'Set the ADODB connection
Set dBConnection = CreateObject("ADODB.Connection")

'Verify for the object existance
If isobject(dBConnection) Then

'Set the connectionstring
dBConnection.ConnectionString = strConnectionString
dBConnection.Provider="MSDASQL.1"

'Open connections
On error resume next
dBConnection.Open(strConnectionString)

'Check for the error number
If not err.number = 0 then
'fnInsertResult "Database Verification", "Verifying the connection with Database", "Error in either connection string", "WARNING"
Reporter.ReportEvent micWarining, "Verifying the connection with Database", "Error in either connection string"
fnDBOpenConnection=false
Exit function
End If
On error goto 0
'fnInsertResult "Database connection", "Verifying the Database connection status ", "Database connection is opened", "PASS"
Reporter.ReportEvent micPass, "Verifying the Database connection status", "Database connection is opened"

'return the connections object back
Set fnDBOpenConnection = dBConnection
Else
'fnInsertResult "Database connection", "Verifying the Database connection status ", "Database connection is not opened", "WARNING"
Reporter.ReportEvent micWarning, "Verifying the Database connection status", "Database connection is not opened"
End If

'reinitialize the object property
Set dBConnection = Nothing

End Function

Close the Database connection

// this function is used to close the Database connection

Set dBConnection - connection object...

Public Function fnDBCloseConnection(dBConnection)
fnDBCloseConnection=false

If isobject(dBConnection) Then
Set dBConnection=dBConnection
dBConnection.Close()
'fnInsertResult "Database connection", "Verifying the Database connection status ", "Database connection is closed", "PASS"
Reporter.ReportEvent micPass, "Verifying the Database connection status", "Database connection is closed"
fnDBCloseConnection=true
Else
'fnInsertResult "Database connection", "Verifying the Database connection status ", "Database connection is closed", "WARNING"
Reporter.ReportEvent micWarning, "Verifying the Database connection status", "Database connection is closed"

End If

Set dBConnection = Nothing
End Function

Connecting to Database

//** this function is used to establis Database connection by sending connection string value.

strConnectionString value should look like DSN=dbAppl;NA=testing,3219;DB=appl_int1;UID=arun;PWD=arun

Public Function fnDBOpenConnection(strConnectionString)
fnDBOpenConnection=false

'Set the ADODB connection
Set dBConnection = CreateObject("ADODB.Connection")

'Verify for the object existance
If isobject(dBConnection) Then

'Set the connectionstring
dBConnection.ConnectionString = strConnectionString
dBConnection.Provider="MSDASQL.1"

'Open connections
On error resume next
dBConnection.Open(strConnectionString)

'Check for the error number
If not err.number = 0 then
'fnInsertResult "Database Verification", "Verifying the connection with Database", "Error in either connection string", "WARNING"
Reporter.ReportEvent micWarining, "Verifying the connection with Database", "Error in either connection string"
fnDBOpenConnection=false
Exit function
End If
On error goto 0
'fnInsertResult "Database connection", "Verifying the Database connection status ", "Database connection is opened", "PASS"
Reporter.ReportEvent micPass, "Verifying the Database connection status", "Database connection is opened"

'return the connections object back
Set fnDBOpenConnection = dBConnection
Else
'fnInsertResult "Database connection", "Verifying the Database connection status ", "Database connection is not opened", "WARNING"
Reporter.ReportEvent micWarning, "Verifying the Database connection status", "Database connection is not opened"
End If

'reinitialize the object property
Set dBConnection = Nothing

End Function