Skip to main content

Web Based Functions -III

Sub CloseBrowser(sBrowserName,sOption,sOR)

If sOR = "OR" then
if sOption = 1 then
if Browser(sBrowserName).Exist then
Browser(sBrowserName).Close
Call GenerateTestStatus(iTestNo, FCR_DONE, "Close Browser", "Browser '" & CStr(sBrowserName) & "' has been closed successfully.")
End if
Else
' Write for Closing all Browser
End if

Else
if sOption = 1 then
if Browser("name:="&sBrowserName).Exist then
Browser("name:="&sBrowserName).Close
Call GenerateTestStatus(iTestNo, FCR_DONE, "Close Browser", "Browser '" & CStr(sBrowserName) & "' has been closed successfully.")
End if
Else
' Write for Closing all Browser
End if
End if
End Sub


Function FrameDate(sDate,sDelim)
'Help
'sDate : Should be in Format "29 May,2007" for Delim as ","
'sDate : Should be in Format "5/29/2007" for Delim as "/"
'sDelim : should be either "," or "/"
'The Fuction will return the dates as "29-May-2007"
If sDelim = "," Then
sYrArr = Split(sDate,sDelim)
'msgbox sYrArr(0)
sDateArr= Split(sYrArr(0)," ")
'msgbox sDateArr(0)
If sDateArr(1) < 10 Then
sFrameDate = "0"&sDateArr(1)&"-"&sDateArr(0)&"-"&sYrArr(1)
Else
sFrameDate = sDateArr(1)&"-"&sDateArr(0)&"-"&sYrArr(1)
End If
Elseif sDelim = "/" Then
sYrArr = Split(sDate,sDelim)
st_Mon = sYrArr(0)
Select Case st_Mon

Case "1"
st_Mon = "Jan"
Case "2"
st_Mon = "Feb"
Case "3"
st_Mon = "Mar"
Case "4"
st_Mon = "Apr"
Case "5"
st_Mon = "May"
Case "6"
st_Mon = "Jun"
Case "7"
st_Mon = "Jul"
Case "8"
st_Mon = "Aug"
Case "9"
st_Mon = "Sep"
Case "10"
st_Mon = "Oct"
Case "11"
st_Mon = "Nov"
Case Else
st_Mon = "Dec"
End Select
If sYrArr(1) < 10 Then
sFrameDate = "0"&sYrArr(1)&"-"&st_Mon&"-"&sYrArr(2)
Else
sFrameDate = sYrArr(1)&"-"&st_Mon&"-"&sYrArr(2)
End If

End if
FrameDate= sFrameDate

'Msgbox sFrameDate
End Function


Sub WaitSync(sBrName,sPgName,sObjectName,sObjType,sObjProp,iIncTime,iTestNo)
Dim iEndTime
iEndTime = 0
'msgbox "At hte begging"&iEndTime
Select Case sObjType
Case "Link"
While(cInt(iEndTime)<=45)
hFrameHwnd = Window("regexpwndclass:=IEFrame", "index:=" & "*").GetROProperty("Hwnd")
Window("hwnd:="& hFrameHwnd).Activate
If Browser(sBrName).Page(sPgName).Link("name:="&sObjectName).Exist(3) then
Exit sub
Else
wait iIncTime
iEndTime = cInt(iEndTime) + cInt(iIncTime)
Reporter.Reportevent MicPass,"WaitSync","The wait time to sync with App is"& iEndTime
End if
Wend
Case "Image"
While(cInt(iEndTime)<=45)
'msgbox "At if "
If Browser("name:="&sBrName).Page("title:="&sPgName).Image("file name:="&sObjectName).Exist(3) then
Exit sub
Else
'msgbox "I am under else:"
wait iIncTime
iEndTime = cInt(iEndTime) + cInt(iIncTime)
Reporter.Reportevent MicPass,"WaitSync","The wait time to sync with App is"& iEndTime
End if
Wend
End Select

End Sub


Sub ClickDomLink(sMainPage,strLinkName,iTestNo)
'str1="Click Link"
bFound = False
'get the collection of <> tags
Set objHTMLDoc = Browser("name:="& sMainPage).Object.Document
Set colATags = objHTMLDoc.GetElementsByTagName("A")
iCount = colATags.length
For i = 0 to iCount - 1 Step 1
'Click on the link to go into the page
If StrComp(Trim(colATags.Item(i).innertext),strLinkName) = 0 Then
'Click on the link
colATags.Item(i).Click
bFound = True
Exit For
End If
Next
If bFound Then
'str2="Found '"& strLinkName &"' and click'd on it"
Call GenerateTestStatus(iTestNo, FCR_PASS, "Click Link in a Table ", "Link '" & strLinkName & "' at "&i&"is clicked Successfully .")
'call MakeReportEvent("PASS",str1,str2)
While objHTMLDoc.ReadyState <> "complete"
Wend
Else
'str2="Unable to find '"& strLinkName &"'."
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Click Link in a Table ", "Link '" & strLinkName & "' is unable to find on Page .")
'call MakeReportEvent("FAIL",str1,str2)
End If

'Wait

Set colATags = Nothing
Set objHTMLDoc = Nothing
End Sub

Sub ClickLink_JL(sBrowserName, sPageName, sLink_Name, iIndexLink,iTestNo)

' HELP
' method: ClickLink
' returns: None
' parameter: sLink_Name,iIndexLink. The sFrame should be Null be if it has to click in Normal Page.
' notes: It will Clicks on the given link in the page/application.
' END

Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).sync

'Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).Link("html tag:=A", "index:=" & iIndexLink, "name:=" & sLink_Name).Highlight
'msgbox Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).Link("html tag:=A", "index:=" & iIndexLink, "name:=" & sLink_Name).Exist
If Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).Link("html tag:=A", "index:=" & iIndexLink, "name:=" & sLink_Name).Exist Then

Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).Link("html tag:=A", "index:=" & iIndexLink, "name:=" & sLink_Name).Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the link", " Name ' " & sLink_Name & "' found and clicked Sucessfully." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the link", " Name ' " & sLink_Name & "' not found to click." )
'Reporter.ReportEvent MicFail, "Click on the link , name ", sLink_Name & " not found to click."
End If



End Sub


Sub CloseBrowser_JL(sBrowserName,sOption)
if Window("regexpwndclass:=IEFrame", "index:=" & "*").Exist then
hFrameHwnd = Window("regexpwndclass:=IEFrame", "index:=" & "*").GetROProperty("Hwnd")
If Browser("hwnd:=" & hFrameHwnd).Exist then
Browser("hwnd:=" & hFrameHwnd).Close
End if
'hFrameHwnd = Window("regexpwndclass:=" & sFramename, "index:=" & iCtr).GetROProperty("Hwnd")
Else

End if

if false then
if sOption = 1 then
if Browser("creationtime:=1","name:="&sBrowserName).Exist then
Browser("creationtime:=1","name:="&sBrowserName).Close
Call GenerateTestStatus(iTestNo, FCR_DONE, "Close Browser", "Browser '" & CStr(sBrowserName) & "' has been closed successfully.")
End if
Else
' Write for Closing all Browser
End if
End if
End Sub
Sub VerifyAmtFormat(sAmountType,sAmount,iTestNo)
'msgbox sAmountType
Select Case sAmountType

Case "Actual" :
If sAmount <> "" Then
sVarArrCh = Mid(sAmount,1,1)
If strComp(sVarArrCh,"(")= 0 Then
sVarArrOne = Mid(trim(sAmount),2,len(trim(sAmount))-2)
sAmtArr = Split(sVarArrOne,".")
If len(cint( sAmtArr(1) )) = 2 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have only two decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "doesn't has two decimal places.")
End if
Else
sAmtArr = Split(sAmount,".")
If len(cint( sAmtArr(1) )) = 2 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have only two decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "doesn't has two decimal places.")
End if
End if
Else
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is empty .")
End If

Case "Whole Dollars" :
If sAmount <> "" Then
If instr(1,sAmount,".",1) = 0 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have no decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "which has decimal places.")
End if
Else
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is empty .")
End If

Case "Thousands" :
If sAmount <> "" Then
sVarArrCh = Mid(sAmount,1,1)
If strComp(sVarArrCh,"(")= 0 Then
sVarArrOne = Mid(trim(sAmount),2,len(trim(sAmount))-2)
sAmtArr = Split(sVarArrOne,".")
If len(sAmtArr(1) ) = 1 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have only one decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "doesn't has two decimal places.")
End if
Else
sAmtArr = Split(sAmount,".")
If len(sAmtArr(1) ) = 1 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have only one decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "doesn't has two decimal places.")
End if
End if
Else
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is empty .")
End If

Case "Millions" :
'msgbox sAmountType & sAmount
If sAmount <> "" Then
sVarArrCh = Mid(sAmount,1,1)
If strComp(sVarArrCh,"(")= 0 Then
sVarArrOne = Mid(trim(sAmount),2,len(trim(sAmount))-2)
sAmtArr = Split(sVarArrOne,".")
'msgbox len(sAmtArr(1) )
If len(sAmtArr(1) ) = 1 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have only one decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "doesn't has two decimal places.")
End if
Else
sAmtArr = Split(sAmount,".")
If len(sAmtArr(1) ) = 1 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have only one decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "doesn't has two decimal places.")
End if
End if
Else
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is empty .")
End If

Case "Billions" :
If sAmount <> "" Then
sVarArrCh = Mid(sAmount,1,1)
If strComp(sVarArrCh,"(")= 0 Then
sVarArrOne = Mid(trim(sAmount),2,len(trim(sAmount))-2)
sAmtArr = Split(sVarArrOne,".")
If len(sAmtArr(1) ) = 1 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have only one decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "doesn't has two decimal places.")
End if
Else
sAmtArr = Split(sAmount,".")
If len(sAmtArr(1) ) = 1 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & " is verfied successfully which have only one decimal places.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is"& sAmount & "doesn't has two decimal places.")
End if
End if
Else
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify the Amount Format ", "Amount type '" & sAmountType & "' and Amount is empty .")
End If
End Select
End Sub



Function GetCellValue(sBrowserName, sPageName,sTableClass,sHtmlId,sRow, sCol,iTestNo)

' HELP
' method: GetCellData()
' returns: Data from a Specific Cell of the table
' parameter: sBrowserName,sPageName,sTableName,sRow,sCol
' parameter:
' notes: To retrieve Data from a Specific Cell of the table
' END
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).Exist Then
GetCellValue = Trim(Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).GetCellData(sRow, sCol))
If GetCellValue <> "" Then
Call GenerateTestStatus(iTestNo, FCR_PASS,"Get Cell value from WebTable", "Web Table '" & CStr(sTableClass) & "' Value is ::" & CStr(GetCellValue) & ".")

Else
Call GenerateTestStatus(iTestNo, FCR_WARNING, "Get Cell value from WebTable", "Web Table '" & CStr(sTableClass) & "' Value is Empty from Cell ::" & CStr(sRow) & "," & CStr(sCol) & ".")

End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Get Cell value from WebTable", "Web Table '" & CStr(sTableClass) & "' No Table Found in Page.")

End If
End Function

Sub ImageClick_OR(sBrowserName,sPageName,sImgFileName,iTestNo)

' HELP
' method: ImageClick
' returns: None
' parameter: sImgName
' notes: This will clicks on the given image link in the page/application.The Image should be in Object Repository.
' END

Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).Image(sImgFileName).Exist Then
Browser(sBrowserName).Page(sPageName).Image(sImgFileName).Click

Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the Image ", " Name ' " & sImgFileName & "' and clicked successfully." )


Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the Image ", " Name ' " & sImgFileName & "' not found to click." )


End If

End Sub



Sub VerifyDateRange(sFromDate,sToDate,sRangeType,iTestNo)

If sFromDate <> "" then
If sToDate <> "" then
iDays = cint(DateDiff("d", sFromDate,sToDate))
'Msgbox iDays
If sRangeType = "Ascending" then
If iDays >= 0 Then
Call GenerateTestStatus (iTestNo,FCR_PASS,"Verify Range of Date ", "Verified sucessfully From-Date '" & sFromDate &"' is in Ascending Order with the '"&sToDate &"'.")
'Msgbox "The Dates reffered in Application were in Ascending Order"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL,"Verify Range of Date ", "From-Date '" & sFromDate &"' is not in Ascending Order with the '"&sToDate& "'.")
'Msgbox "The Dates reffered in Application were not in Ascending Order"
End If
Else

If sRangeType = "Descending" then
If iDays < 0 Then
Call GenerateTestStatus (iTestNo,FCR_PASS,"Verify Range of Date ", "Verified sucessfully From-Date '" & sFromDate &"' is in Descending Order with the '"&sToDate &"'.")
'Msgbox "The Dates reffered in Application were in Descending Order"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL,"Verify Range of Date ", "From-Date '" & sFromDate &"' is not in Descending Order with the '"&sToDate& "'.")
'Msgbox "The Dates reffered in Application were not in Descending Order"
End If
End if
End if
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL,"Verify Range of Date ", "The From-Date '" & sFromDate &"' is Empty to Validate.")
'Msgbox "The To-Date reffered in Application were Empty to validate"
End if
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL,"Verify Range of Date ", "The To-Date '" & sToDate &"' is Empty to Validate.")
'Msgbox "The From-Date reffered in Application were Empty to validate"
End if


End Sub


Function GetWebListDefaultValue(sBrowserName, sPageName, sWebListName,iIndex,iTestNo)

' HELP
' method: GetWebListDefaultValue(sBrowserName,sPageName,sWebListName,iIndex) ' returns: None
' parameter: sWebListName as Name of the WebEdit to retrieve the Default Value
' parameter:
' notes: This is used to Retrieve Default item of a Web List in Page
' END

Dim sBrowserName_MaintainSales
Dim sDefaultValue
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebList("name:=" & sWebListName, "html tag:=SELECT", "index:=" & iIndex).Exist Then
sWebListState = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sWebListName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("disabled")
If (sWebListState = 0) Then
sDefaultValue = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sWebListName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("Value")
If sDefaultValue <> "" Then
GetWebListDefaultValue = sDefaultValue
Call GenerateTestStatus (iTestNo,FCR_PASS, "Get default value in Web List ", "The default value from weblist "&sWebListName&"in application retrieved is " & CStr(sDefaultValue) &".")

Else
GetWebListDefaultValue = sDefaultValue
Call GenerateTestStatus (iTestNo,FCR_FAIL,"Get default value in Web List ", "The default value from weblist "&sWebListName&"in application is empty to retrieve.")

End If
Else

Call GenerateTestStatus (iTestNo,FCR_FAIL,"Verify Web List Value ", "Name '" & CStr(sWebListName)&"' is in Disabled State, So Unable to Verify the Web list Value.")

End If
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL,"Verify Web List Value ", "Name '" & CStr(sWebListName)&"'Doesn't Exists to Verify default list Value.")

End If
End Function



Function VerifyDisplayTextNotFound(sBrowserName,strTagName,strMessage,iTestNo)

' HELP
' method: VerifyDisplayTextNotFound()
' returns: Pass/Fail of the execution(0/1).
' parameter: strTagName: Name of the Html Tag which to be verified.
' parameter: strMessage: Expected string which to be verified is passed

' notes: This function verifies whether string passed as input is found or not.
' END
Dim i
bFound = False
Set objHTMLDoc = Browser("name:="& sBrowserName).Object.Document
Set colTags = objHTMLDoc.GetElementsByTagName(strTagName)
iCount = colTags.length
For i = 0 to iCount - 1 Step 1
'Chekc for the message
'Msgbox UCase(trim(colTags.Item(i).innertext))& "is Checked with" &UCase(trim(strMessage))

If strcomp(UCase(trim(colTags.Item(i).innertext)),UCase(trim(strMessage)))=0 Then
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify text in Page", "Verified '"& strMessage &"' message successfully on the page '"&sBrowserName& "'.")
bFound = True
Exit For
End If

Next
If Not bFound Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify text in Page", "Verified '"& strMessage &"' message not found on the page'"&sBrowserName& "'.")

End If

Set colTags = Nothing
Set objHTMLDoc = Nothing
VerifyDisplayTextNotFound = bFound
End Function
Function OperateTableCheckBox_Str(sBrowserName, sPageName, sHtmlId,sStr,sFileType,sStrCol,sLinkCol,sChkBoxCol,sOperation,iTestNo)

' HELP
' method: OperateTableCheckBox_Str()
' returns:
' parameter: sRow,sCol as Row &Col to Select/Deselect any Check Box of a Table
' parameter: sStr meant for reference no. in rpt mngr table, This can be validated/not based on the passed value
' notes: Check box will be made on or off based on the specified string (which is one of the table Cell value, is option made ON/OFF.)
' notes: Selection Check box in the Specified table is option made ON/OFF .
' END

Dim SetCheckBox
'Msgbox Browser(sBrowserName).Page(sPageName).Exist
Browser(sBrowserName).Page(sPageName).sync

If Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).Exist Then
iRowCnt = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).RowCount

If sStr<>"" Then

For iRCnt = 1 to iRowCnt

sActCellData = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).GetCellData(iRCnt,sStrCol)
'Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).GetCellData(iRCnt,sStrCol)

if strComp(trim(sStr),trim(sActCellData)) = 0 then
'Msgbox "The string Found at: "& iRCnt
sChkBoxRow = iRCnt
'Msgbox "the string find at: " &iRCnt
Exit For
End if
Next

End If
sActFileName = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).GetCellData(sChkBoxRow,sLinkCol)
'msgbox sActFileName &":::" & sFileType
If strComp(trim(sFileType),trim(sActFileName)) = 0 then
If sChkBoxCol <> "" Then





If sChkBoxRow <> "" Then
SetCheckBoxexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).ChildItemCount(sRow, sCol, "WebCheckBox"))
'Msgbox sChkBoxRow & SetCheckBoxexist
If SetCheckBoxexist <> 0 Then
Set SetCheckBox = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).ChildItem(sChkBoxRow,sChkBoxCol, "WebCheckBox", 0)

SetCheckBox.Set sOperation
Call GenerateTestStatus(iTestNo, FCR_PASS, "Operate Check Box in Table ", sStr &" string found and Check Box" & " in table at Row" & CStr(sChkBoxRow) & ", Column " & CStr(sChkBoxCol) & " is made "&sOperation&".")
'Reporter.ReportEvent MicPass, "Operate Check Box in Table ", sStr &" string found and Check Box" & " in table at Row" & CStr(sChkBoxRow) & ", Column " & CStr(sChkBoxCol) & " is made "&sOperation&"."
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Operate Check Box in Table ", sStr &" string found and Check Box" & " in table at Row" & CStr(sChkBoxRow) & ", Column " & CStr(sChkBoxCol) & " is not found.")
'Reporter.ReportEvent MicFAIL, "Operate Check Box in Table ", "Check Box '" & sCheckBox & "' in table at Row" & CStr(sChkBoxRow) & ", Column " & CStr(sChkBoxCol) & " is made "&sOperation&"."
End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Operate Check Box in Table ", "Expected String '" & sStr & "' in table is not found.")
'Reporter.ReportEvent MicFAIL, "Operate Check Box in Table ", "Expected String '" & sStr & "' in table is not found."
End If

Else
'Msgbox "HHH"


If sLinkCol <> "" Then
'Msgbox sLinkCol
SetLinkexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).ChildItemCount(sChkBoxRow, sLinkCol, "Link"))
'msgbox SetLinkexist
if SetLinkexist <> 0 Then
Set SetLink = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).ChildItem(sChkBoxRow,sLinkCol,"Link", 0)
SetLink.highlight
SetLink.Click
Call GenerateTestStatus(iTestNo, FCR_PASS, "Operate Click Link in Table ", sStr &" string found and Link" & " in table at Row" & CStr(sChkBoxRow) & ", Column " & CStr(sLinkCol) & " is Clicked successfully.")
'Reporter.ReportEvent MicPass, "Operate Click Linkin Table ", sStr &" string found and Check Box" & " in table at Row" & CStr(sChkBoxRow) & ", Column " & CStr(sChkBoxCol) & " is made "&sOperation&"."
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Operate Click Link in Table ", sStr &" string found and Link" & " in table at Row" & CStr(sChkBoxRow) & ", Column " & CStr(sLinkCol) & " is not found.")
'Reporter.ReportEvent MicFAIL, "Operate Click Link in Table ", "Check Box '" & sCheckBox & "' in table at Row" & CStr(sChkBoxRow) & ", Column " & CStr(sChkBoxCol) & " is made "&sOperation&"."
End If
End if

End if


Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Operate Link in Table ", "FileType '" & sType & "' is not found.")
End if

Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Operate Check Box in Table ", "Table '" & sTableName & "' is not found.")
End if
End Function




Function CheckFileExists (sFilePath)

' The Function will return true or false based on the file existence

dim oFSO
set oFSO = CreateObject ("Scripting.FileSystemObject")
' check if file exist
CheckFileExists = oFSO.FileExists(sFilePath)
If CheckFileExists then
Call GenerateTestStatus(iTestNo, FCR_PASS, "CheckFileExists ", "Expected File '" & sFilePath & "' is existed.")
Else
Call GenerateTestStatus(iTestNo, FCR_WARNING, "CheckFileExists ", "Expected File '" & sFilePath & "' is not existed.")
End if

set oFSO = Nothing

End Function


Sub ExcelCompare(sBaseRefFilePath,sActualFilePath)
BaseArr = split(sBaseRefFilePath,".")
BaseBookArr = split(BaseArr(0),"\")
sBaseBook = BaseBookArr(Ubound(BaseBookArr))
ActualArr = split(sActualFilePath,".")
ActualBookArr = split(ActualArr(0),"\")
sActualBook = ActualBookArr(Ubound(ActualBookArr))

Set ExcelApp = CreateObject("Excel.Application")
On Error Resume Next
Set BaseRefbook = ExcelApp.Workbooks.Open(sBaseRefFilePath)
Set OpenBaseRefbook = BaseRefbook
Set Actualbook = ExcelApp.Workbooks.Open(sActualFilePath)
Set OpenActualbook = Actualbook
On Error GoTo 0
If not OpenBaseRefbook is Nothing Then
Set Baseworkbook = ExcelApp.Workbooks(sBaseBook)
Set Basesheet = Baseworkbook.Sheets(1)
Set EndCell = Basesheet.UsedRange
lastRow = EndCell(EndCell.Count).Row
lastCol = EndCell(EndCell.Count).Column
If not OpenBaseRefbook is Nothing Then
Set Actualworkbook = ExcelApp.Workbooks(sActualBook)
Set Actualsheet = Actualworkbook.Sheets(1)
'Msgbox lastRow&lastCol
For iRow = 1 to lastRow
For iCol = 1 to lastCol

If Basesheet.Cells(iRow,iCol).value = Actualsheet.Cells(iRow,iCol).value Then

Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Cell Value", "The Cell value '"&Basesheet.Cells(iRow,iCol).value &"' from BaseBook" &sBaseBook &"is matched with value '"&Basesheet.Cells(iRow,iCol).value &"' from ActualBook"&sActualBook&".")
'Reporter.ReportEvent 0, "Verify Cell Value", "The Row No. '" & iRow &"' is matched with '"& iCol &"' for Value: "&worksheet3.Cells(iRow,iCol)
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Cell Value", "The Cell value '"&Basesheet.Cells(iRow,iCol).value &"' from BaseBook" &sBaseBook &" doesn't match with value '"&Basesheet.Cells(iRow,iCol).value &"' from ActualBook"&sActualBook&".")
'Reporter.ReportEvent 1, "Verify Cell Value", "The Row No. '" & iRow &"' doesn't matched with '"& iCol &"' for Value: " &worksheet3.Cells(iRow,iCol)
End If
Next
Next
Else
Report.ReportEvent micPass,"Excel Compare", "The Book '"&sBaseBook &"' passed is Bad Book Identifier"
End if
Else
Report.ReportEvent micPass,"Excel Compare", "The Book '"&sActualBook &"' passed is Bad Book Identifier"

End If

Set OpenBaseRefbook = nothing
Set BaseRefbook = nothing
Set Actualbook = nothing
Set OpenActualbook = nothing
Set Baseworkbook = nothing
Set Actualworkbook= nothing
Set Basesheet = nothing
Set Actualsheet= nothing
Set ExcelApp = nothing

End Sub

Function SaveFile_Win(sFileName)


If Browser("Browser").Dialog("regexpwndtitle:=File Download").Exist Then
'Browser("Browser").Dialog("File Download").WinButton("Save").Highlight
If Browser("Browser").Dialog("regexpwndtitle:=File Download").WinButton("regexpwndtitle:=&Save").Exist then
Browser("Browser").Dialog("regexpwndtitle:=File Download").WinButton("regexpwndtitle:=&Save").Highlight
Browser("Browser").Dialog("regexpwndtitle:=File Download").WinButton("regexpwndtitle:=&Save").Click
wait 2
'Msgbox "Save is Clicked"
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the Button", " Name: ' Save' found in Dialog 'File Down load' and clicked Sucessfully." )
If Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").WinEdit("nativeclass:=Edit","attached text:=File &name:").exist then
Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").WinEdit("nativeclass:=Edit","attached text:=File &name:").set sFileName

If Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").WinButton("regexpwndtitle:=&Save").exist then
Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").WinButton("regexpwndtitle:=&Save").Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the Button", " Name: ' Save' found in Dialog 'Save As' and clicked Sucessfully." )
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the Button", " Name: '" & sFileName &"' is saved Sucessfully." )
'Msgbox "File name is inputted and Save is Clicked"

If Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").Dialog("regexpwndtitle:=Save As").Winbutton("regexpwndtitle:=&Yes").exist(1) Then
Dialog("File Download").Dialog("Save As").Dialog("Save As").Winbutton("regexpwndtitle:=&Yes").Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the Button", " Name: '" & sFileName &"' is resaved Sucessfully." )

SaveFile_Win = True
End If



If Dialog("Download complete").WinButton("nativeclass:=Button","text:=Close").Exist Then
'Dialog("Download complete").WinButton("Close").Highlight
Dialog("Download complete").WinButton("nativeclass:=Button","text:=Close").Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the Button", " Name: ' Close' found in Dialog 'Download complete' and clicked Sucessfully." )
SaveFile_Win = True
'Msgbox "Close Button exists and clicked sucessfully"
End If

Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the Button", " Name: ' Save As' is not found in Dialog 'Save As' ." )
SaveFile_Win = False
'Msgbox "There is no File name is inputted and Save is Clicked"
End If
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the Button", " Value inputted in win edit and Name: ' Save' is not found in Dialog 'File Down load'." )
SaveFile_Win = False
End if
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the Button", " Name: ' Save' is not found in Dialog 'File Down load' ." )
SaveFile_Win = False
' Msgbox "There is no File Download"
End if
Else

SaveFile_Win = False
End if
End Function



Sub VarCalculator(sBaseRefFilePath)
BaseArr = split(sBaseRefFilePath,".")
BaseBookArr = split(BaseArr(0),"\")
sBaseBook = BaseBookArr(Ubound(BaseBookArr))
Set ExcelApp = CreateObject("Excel.Application")
On Error Resume Next
Set BaseRefbook = ExcelApp.Workbooks.Open(sBaseRefFilePath)
Set OpenBaseRefbook = BaseRefbook
On Error GoTo 0
If not OpenBaseRefbook is Nothing Then
Set Baseworkbook = ExcelApp.Workbooks(sBaseBook)
Set Basesheet = Baseworkbook.Sheets(1)
Set EndCell = Basesheet.UsedRange
lastRow = EndCell(EndCell.Count).Row
lastCol = EndCell(EndCell.Count).Column

'If false Then

For i = 10 to lastRow

For j = lastCol to 7 step -1
'Reporter.ReportEvent MicPass, "Value of Excel","Value from Excel sheeet is for i " &i &"and "& "j: " &j &"with value: "&Basesheet.Cells(i,j).value
If Basesheet.Cells(i,j).value = "Variance" and Basesheet.Cells(i,j-1).value= "Variance" Then
If IsDate(Basesheet.Cells(i,j-2).Value) and IsDate(Basesheet.Cells(i,j-3).value) Then
i =i+5
'Msgbox "For Zero at Diff:"& CCur(Basesheet.Cells(i+1,j-2).value)
If CCur(Basesheet.Cells(i+1,j-2).value) <> 0 Then

If CCur(Basesheet.Cells(i+1,j-3).value) - CCur(Basesheet.Cells(i+1,j-2).value) = CCur(Basesheet.Cells(i+1,j-1).value) Then
'Msgbox "Value from Excel sheeet is for i " &i+1 &"and "& "j: " &j-1&"with value: "&Basesheet.Cells(i+1,j-1).value
'Call GenerateTestStatus (iTestNo,FCR_PASS, "Variance calculation in CSV File", "Variance amount from sheeet for row " &i+1 &"and column " &j-1&"with value: "&Basesheet.Cells(i+1,j-1).value&" is matched sucessfully." )
'Reporter.ReportEvent MicPass, "Value of Excel","Value from Excel sheeet is for i " &i+1 &"and "& "j: " &j-1&"with value: "&Basesheet.Cells(i+1,j-1).value

sVarDiff= CCur(Basesheet.Cells(i+1,j-3).value) - CCur(Basesheet.Cells(i+1,j-2).value)
'Msgbox "For Zero at Diff:"& sVarDiff
If sVarDiff <> 0 Then

sVarPer = Round(sVarDiff/ccur(Basesheet.Cells(i+1,j-2))*100,2)
'Msgbox "Before Rounding is; "&sVarDiff/ccur(Basesheet.Cells(i+1,j-2))*100 & "and after rounding: " & sVarPer
sLsVarPer = Mid(sVarPer,len(sVarPer),1)
If sLsVarPer < 5 Then
sVarPer = Mid(sVarPer,1,len(sVarPer)-1)
'Msgbox sVarPer
Else
sVarPer = Mid(sVarPer,1,len(sVarPer)-1)
sVarPer = sVarPer+0.1
End If

'Msgbox "Matcjhes2: "&sVarPer& "and " & CCur(Basesheet.cells(i+1,j)*100)

If cdbl(sVarPer) = cdbl(CCur(Basesheet.cells(i+1,j).value*100)) then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Variance calculation in CSV File", "Variance amount from sheeet for row " &i+1 &"and column " &j-1&"with value: "&Basesheet.Cells(i+1,j-1).value&" is matched sucessfully." )
Call GenerateTestStatus (iTestNo,FCR_PASS, "Variance calculation in CSV File", "Variance Percentage from sheeet for row " &i+1 &"and column " &j&"with value: "&cDbl(ccur(Basesheet.Cells(i+1,j).value))&" is matched sucessfully." )
'Reporter.ReportEvent MicWarning,"Value of Excel","Value from Excel sheeet is for i " &i+1 &"and "& "j: " &j&"with value: "&Basesheet.Cells(i+1,j).value
Exit Sub
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Variance calculation in CSV File", "Variance Percentage from sheeet for row " &i+1 &"and column " &j&"with value: "&cDbl(ccur(Basesheet.Cells(i+1,j).value))&" doesn't matched sucessfully." )
Exit Sub
End If

Else
'Msgbox "sVarDiff is equal to 0 "
sVarPer = "0.00"
If cDbl(sVarPer) = cDbl(CCur(Basesheet.cells(i+1,j).value*100)) then
'Msgbox "The Values are matched with : " & cDbl(sVarPer) & "and " & cDbl(CCur(Basesheet.cells(i+1,j).value*100))
Call GenerateTestStatus (iTestNo,FCR_PASS, "Variance calculation in CSV File", "Variance amount from sheeet for row " &i+1 &"and column " &j-1&"with value: "&Basesheet.Cells(i+1,j-1).value&" is matched sucessfully." )
Call GenerateTestStatus (iTestNo,FCR_PASS, "Variance calculation in CSV File", "Variance Percentage from sheeet for row " &i+1 &"and column " &j&"with value: "&cDbl(ccur(Basesheet.Cells(i+1,j).value))&" is matched sucessfully." )
'Msgbox "true"
Exit Sub
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Variance calculation in CSV File", "Variance Percentage from sheeet for row " &i+1 &"and column " &j&"with value: "&cDbl(ccur(Basesheet.Cells(i+1,j).value))&" doesn't matched sucessfully." )
Exit Sub
End if

End If

Else '888
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Variance calculation in CSV File", "Variance Amount from sheeet for row " &i+1 &"and column " &j&"with value: "&Basesheet.Cells(i+1,j).value&" doesn't matched sucessfully." )
Exit Sub

End If

Else
'Msgbox "The Diff should be same as Current One: "
sVarDiff = CCur(Basesheet.Cells(i+1,j-3).value)
sVarPer = "0.00"


If cdbl(sVarPer) = cdbl(CCur(Basesheet.cells(i+1,j).value*100)) then


Call GenerateTestStatus (iTestNo,FCR_PASS, "Variance calculation in CSV File", "Variance amount from sheeet for row " &i+1 &"and column " &j-1&"with value: "&Basesheet.Cells(i+1,j-1).value&" is matched sucessfully." )
Call GenerateTestStatus (iTestNo,FCR_PASS, "Variance calculation in CSV File", "Variance Percentage from sheeet for row " &i+1 &"and column " &j&"with value: "&cDbl(ccur(Basesheet.Cells(i+1,j).value))&" is matched sucessfully." )

'Msgbox "true"
'Reporter.ReportEvent MicWarning,"Value of Excel","Value from Excel sheeet is for i " &i+1 &"and "& "j: " &j&"with value: "&Basesheet.Cells(i+1,j).value
Exit Sub
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Variance calculation in CSV File", "Variance Percentage from sheeet for row " &i+1 &"and column " &j&"with value: "&Basesheet.Cells(i+1,j).value&" doesn't matched sucessfully." )
Exit Sub

End If

End If

End if
End if
Next
Next
'End If
'Msgbox CSng(Basesheet.cells(19,12).value*100)&"-"& CCur(Basesheet.cells(20,12).value*100)&"-"& CCur(Basesheet.cells(21,12).value*100)&"-"& CCur(Basesheet.cells(22,12).value*100)
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Variance calculation in CSV File", "The Book '"&sBaseBook&"' passed is Bad Book Identifier" )

End If

Set OpenBaseRefbook = nothing
Set BaseRefbook = nothing
Set Baseworkbook = nothing
Set Basesheet = nothing
Set ExcelApp = nothing


End Sub

Sub SaveFile_Browser(sBrowserName,sFileType,sFileName)

sTitle = Browser(sBrowserName).GetROProperty("title")
'Msgbox sTitle & InStr(sTitle,"fileType="&Ucase(sFileType))
If InStr(sTitle,"fileType="&Ucase(sFileType)) <> 0 then

Reporter.ReportEvent MicPass,"The File Format", "The File format '"&UCase(sFileType)&"' is existed to save."
Browser(sBrowserName).WinToolbar("ToolbarWindow32").Press "&File"
Browser(sBrowserName).WinMenu("ContextMenu").Select "Save As..."
Browser(sBrowserName).Dialog("Save a Copy").WinEdit("File name:").Set sFileName
If Browser(sBrowserName).Dialog("Save a Copy").WinButton("Save").Exist then
Browser(sBrowserName).Dialog("Save a Copy").WinButton("Save").Click
Reporter.ReportEvent MicPass,"Click WinButton","The save button is clicked sucessfully in window 'Save a Copy'"
If Browser("Browser").Dialog("Save a Copy").Dialog("Save As").WinButton("Yes").Exist then
Browser("Browser").Dialog("Save a Copy").Dialog("Save As").WinButton("Yes").Click
Reporter.ReportEvent MicPass,"Click WinButton","The Yes button is clicked sucessfully in window 'Save As'"
End if
Else
Reporter.ReportEvent MicPass,"Click WinButton","The save button is not existed in window 'Save a Copy'"
end if


Else
Reporter.ReportEvent MicFail,"The File Format", "The File format '"&UCase(sFileType)&"' is not existed "
End If

End Sub


'Added on 19-Oct-07 by srihari

Sub VerifyWBEltLBL(sBrowserName, sPageName, sWBEltName,sWBELTClass,sExpTitle,iTestNo)


' HELP
' method: VerifyTextInWBElt()
' returns: None
' parameter: sBrowserName sWBEltName: Innertext of WBElement
'(Ex: if innertext as "ActualWhole" has to be passed instead of orginal "ActualWhole Number (no decimals)"
' parameter: sExpTitle-Expected Title of the page which to be tested
' notes: Verifies the Expected Title of the page which to be tested
' END

Dim oDesc
Dim sTitle

Browser(sBrowserName).Page(sPageName).sync
'msgbox "IIndex is: " & iIndex&Browser(sBrowserName).Page(sPageName).WebElement("innertext:="&sWBEltName,"class:="&sWBELTClass,"index:="&iIndex).Exist

If Browser(sBrowserName).Page(sPageName).WebElement("innertext:="&sWBEltName,"class:="&sWBELTClass,"index:="&iIndex).Exist Then
stext = Browser(sBrowserName).Page(sPageName).WebElement("innertext:="&sWBEltName,"class:="&sWBELTClass,"index:="&iIndex).GetROProperty("innertext")
'msgbox stext
If InStr(LCase(stext), LCase(sExpTitle)) <> 0 Then


Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify text in Page", "'"& sExpTitle & "' successfully verified on the page '"&sPageName&"'." )



Else

Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify text in Page", "'"& sExpTitle & "' doesn't exist in Page." )


End If
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify text in page", " WebElement '" & sWBEltName & "' doesn't exist." )

End If

End Sub

Sub StringCompare(sExpStr,sActStr,iTestNo)

If strcomp(trim(UCASE(sExpStr)),trim(UCASE(sActStr)),1) = 0 then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify String in Page", "'"& sExpStr & "' successfully matched with '"& sActStr & "' on the page." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify String in Page", "'"& sExpStr & "' is not matched with '"& sActStr& "' on the page." )
End If
End Sub


'Added on 25-Oct-07 by srihari


Sub OperateClickLink_TableClass(sBrowserName, sPageName,sTableClass,sHtmlId,sRow, sCol,iTestNo)

' HELP
' method: OperateTableCheckBoxNOR
' returns: None
' parameter: sTableName,iIndex
' parameter: sRow,sCol as Row &Col to Select/Deselect any Check Box of a Table
' notes: Selection of Check box in the Specified table is option made ON/OFF .
' Notes: No need to keep in object repository
' END

Dim SetCheckBox
Browser(sBrowserName).Page(sPageName).sync
'MSgbox sBrowserName&sPageName&sTableClass&sHtmlId
'msgbox Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).Exist

If Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).Exist Then
GetLinkName = Trim(Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).GetCellData(sRow, sCol))
'Msgbox GetLinkName
If GetLinkName <> "" Then
setLinkexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).ChildItemCount(sRow, sCol, "Link"))
'msgbox "Existence:"& setLinkexist
If setLinkexist = 1 Then
Set SetLink = Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).ChildItem(sRow, sCol, "Link", 0)
SetLink.Click
Call GenerateTestStatus(iTestNo, FCR_PASS,"Click Link in WebTable", "Web Table '" & CStr(sTableClass) & "' Value is ::" & CStr(GetLinkName) & " is clicked sucessfully.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL,"Click Link in WebTable", "Web Table '" & CStr(sTableClass) & "' Value is ::" & CStr(GetLinkName) & "is not found in the Page.")
End if

Else
Call GenerateTestStatus(iTestNo, FCR_WARNING, "Click Link in WebTable", "Web Table '" & CStr(sTableClass) & "' Value is Empty from Cell ::" & CStr(sRow) & "," & CStr(sCol) & ".")
End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Click Link in WebTable ", "Web Table '" & CStr(sTableClass) & "' not found in a given Page :" & CStr(sPageName) & ".")
End If


End Sub

Function GetWBEltHtmlID(sBrowserName, sPageName, sWBEltName,sHtmlTag,iTestNo)


' HELP
' method: GetWBEltHtmlID()
' returns: None
' parameter: sBrowserName sWBEltName: Innertext of WBElement

' parameter: html tag of expected web element
' notes: Retrieves the html ID of the page which to be tested
' END

Dim oDesc
Dim sTitle

Browser(sBrowserName).Page(sPageName).sync
'msgbox "IIndex is: " & iIndex&Browser(sBrowserName).Page(sPageName).WebElement("innertext:="&sWBEltName,"html tag:="&sHtmlTag,"index:="&iIndex).Exist

If Browser(sBrowserName).Page(sPageName).WebElement("innertext:="&sWBEltName,"html tag:="&sHtmlTag,"index:="&iIndex).Exist Then
GetWBEltHtmlID = Browser(sBrowserName).Page(sPageName).WebElement("innertext:="&sWBEltName,"html tag:="&sHtmlTag,"index:="&iIndex).GetROProperty("html id")
Call GenerateTestStatus (iTestNo,FCR_PASS, "Get WebElement Html Id", " WebElement '"&sWBEltName & "' is found and htmlid '"& GetWBEltHtmlID & "' is retrived from the page '"&sPageName&"'.")


Else

Call GenerateTestStatus (iTestNo,FCR_FAIL, "Get WebElement Html Id", " WebElement '"&sWBEltName & "' doesn't exist in the page'"&sPageName&"'.")
End If


End Function


Sub DeleteCookies(sIntranetURL,sBrowserName,iTestNo)
' HELP
' method: DeleteCookies()
' returns:
' parameter: sBrowserName
' parameter:
' notes: Delete the previous Cookies and History and files from the inputted browser.
' END
'Call TestSettings(TB_OR_PATH,"FCR_OR_BrowserCookies.tsr")
'If false then
Systemutil.Run "iexplore.exe",sIntranetURL
wait 10

Set objShell=CreateObject("WScript.Shell")
objShell.SendKeys"%"+"T"
Wait(2)
objShell.SendKeys"O"
Wait(2)
objShell.SendKeys"%"+"I"
Wait(2)
objShell.SendKeys"{ENTER}"
objShell.SendKeys"%"+"F"
Wait(1)
objShell.SendKeys"D"
wait(1)
objShell.SendKeys"{ENTER}"
Wait(2)
'objShell.SendKeys"%"+"H"
'Wait(1)
'objShell.SendKeys"%"+"Y"
'Wait(6)
objShell.SendKeys"%"+"K"
Wait(1)
objShell.SendKeys"%"+"K"
Wait(2)
objShell.SendKeys"{TAB}"
Wait(1)
objShell.SendKeys"{TAB}"
Wait(1)
objShell.SendKeys"{TAB}"
Wait(1)
objShell.SendKeys"{TAB}"
Wait(1)
objShell.SendKeys"{TAB}"
Wait(1)
objShell.SendKeys"{TAB}"
Wait(1)
objShell.SendKeys"{ENTER}"
Wait(1)
'msgbox "Shell"
Set objShell= Nothing


Call CloseBrowser_JL(sBrowserName,FCR_ONE)
'end if
End Sub

Function MakeFolder(sFolderpath)

set oFSO = CreateObject ("Scripting.FileSystemObject")
bFolderExists = oFSO.FolderExists(sFolderpath)
'Msgbox bFolderExists
If not bFolderExists Then
sFldrAr = split(sFolderpath,"\")
'msgbox sFldrAr(1)
If Ubound(sFldrAr) >1 Then

If not oFSO.FolderExists(sFldrAr(0)&"\"&sFldrAr(1)) Then
oFSO.CreateFolder sFldrAr(0)&"\"&sFldrAr(1)
Else
oFSO.CreateFolder sFldrAr(0)&"\"&sFldrAr(1)&"\"&sFldrAr(2)
End if

Else
oFSO.CreateFolder sFldrAr(0)&"\"&sFldrAr(1)
End if
MakeFolder = sFolderpath
End If
MakeFolder = sFolderpath
set sFldrAr = Nothing
set oFSO = Nothing
End Function


Sub VerifyTableLinkExistence(sBrowserName, sPageName,sTableClass,sHtmlId,sRow,sCol,sExpLinkstate,iTestNo)

' HELP
' method: VerifyTableLinkExistence
' returns: None
' parameter: sTableClass,sHtmlId,sExpLinkstate(either in True or False)
' parameter: sRow,sCol as Row &Col to check any Link in specified cell address of a Table
' notes: Verifies for the existence of Link in the Specified table based on True or False user input .
' Notes:
' END

Dim SetCheckBox
Browser(sBrowserName).Page(sPageName).sync
'msgbox Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext).Exist

If Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).Exist Then
GetLinkName = Trim(Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).GetCellData(sRow, sCol))
'Msgbox GetLinkName
If GetLinkName <> "" Then
setLinkexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable("class:="&sTableClass,"html id:="&sHtmlId).ChildItemCount(sRow, sCol, "Link"))
If sExpLinkstate = "False" then
sExpLinkstate = "0"
Else
sExpLinkstate = "1"
End If



'msgbox "Existence:"& setLinkexist
If setLinkexist = sExpLinkstate Then

Call GenerateTestStatus(iTestNo, FCR_PASS,"Verify Link in WebTable", "Web Table '" & CStr(sTableClass) & "' Link Name ::" & CStr(GetLinkName) & " expected link state '"& sExpLinkstate &"' successfully matched in the page.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL,"Verify Link in WebTable", "Web Table '" & CStr(sTableClass) & "' Link Name ::" & CStr(GetLinkName) & " expected link state '"& sExpLinkstate &"' doesn't successfully matched in the page.")
End if


Else
Call GenerateTestStatus(iTestNo, FCR_WARNING, "Click Link in WebTable", "Web Table '" & CStr(sTableClass) & "' Value is Empty from Cell ::" & CStr(sRow) & "," & CStr(sCol) & ".")
End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Click Link in WebTable ", "Web Table '" & CStr(sTableClass) & "' not found in a given Page :" & CStr(sPageName) & ".")
End If


End Sub


Sub EnterData_OR(sBrowserName, sPageName, sEdName,sValue,iTestNo)

' HELP
' method: EnterData
' returns: None
' parameter: sEdName,sValue
' notes: This will enter the given data in the given text box
' END

Browser(sBrowserName).Page(sPageName).sync
'msgbox Browser(sBrowserName).Page(sPageName).Exist
'msgbox Browser(sBrowserName).Page(sPageName).WebEdit(sEdName).Exist
If Browser(sBrowserName).Page(sPageName).WebEdit(sEdName).Exist(1) Then
Browser(sBrowserName).Page(sPageName).WebEdit(sEdName).Set sValue

Call GenerateTestStatus (iTestNo,FCR_PASS, "Enter data in the EditBox ", " Name '" & CStr(sEdName) & "' is exist and data '" & CStr(sValue) & "' is entered." )
'Reporter.ReportEvent MicPass, "Enter data in the field name ", CStr(sEdName) + "is exist and data" + CStr(sValue) + " is entered."
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Enter data in the EditBox ", " Name '" & CStr(sEdName) & "' not exists.")
'Reporter.ReportEvent MicFail, "Enter data in the field name ", sEdName & " not exist."
End If

End Sub


Sub VerifyCheckBoxStatus(sBrowserName,sPageName,sInnertext,sRow,sCol,sChkStatus,iTestNo)

' HELP
' method: VerifyCheckBoxStatus
' returns: None
' parameter: sBrowserName,sPageName,sInnertext,sRow,sCol,sChkStatus,iTestNo
' Example for checking disabled status as "disabled"
' notes: This will verify for the existence of CheckBox
' END



Browser(sBrowserName).Page(sPageName).sync
'Msgbox Browser(sBrowserName).Page(sPageName).Exist
'Msgbox Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext,"index:="&iIndex).Exist

If Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext,"index:="&iIndex).Exist Then
sWebChkboxexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext,"index:="&iIndex).ChildItemCount(sRow, sCol, "WebCheckBox"))
'msgbox "Existence:"& sWebChkboxexist
'If sWebChkboxexist = 1 Then
Set SetCheckBox = Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext,"index:="&iIndex).ChildItem(sRow, sCol,"WebCheckBox", 0)

sOuterHtml = SetCheckBox.getroproperty("outerhtml")
sOtrHtmlArr1 = Split(sOuterHtml,"=")
sOtrHtmlArr = Split(sOtrHtmlArr1(1)," ")
If strcomp(sOtrHtmlArr(1),sChkStatus,1) = 0 then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Verify Check Box status ", "Check Box '" & sInnertext & "' in table at Row" & CStr(sRow) & ", Column " & CStr(sCol) & " is in "&sChkStatus&".")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify Check Box status ", "Check Box '" & sInnertext & "' in table at Row" & CStr(sRow) & ", Column " & CStr(sCol) & " is not in "&sChkStatus&".")
End if

Else
'Msgbox "Web Table '" & CStr(sTableName) & "' not found in a given Page :" & CStr(sPageName) & "."
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Verify Check Box status ", "Web Table '" & CStr(sInnertext) & "' not found in a given Page :" & CStr(sPageName) & ".")

End If
End sub

Sub InputDate_OR( sBrowserName,sPageName,sCalImage,sCalNxtYr,sCalPrevYr,sCalNxtMn,sCalPrevMn,sExpDate,iDtIndx,iTestNo)

Dim iYrDiff,iMonDiff,sDateLinkName

iYrDiff = Year(Now) - Year(sExpDate)
iMonDiff =Month (Now) - Month(sExpDate)
sDateLinkName = day(sExpDate)

'iIndex = FCR_NULL
'msgbox Browser(sBrowserName).Page(sPageName).Exist
'msgbox Browser(sBrowserName).Page(sPageName).Image("file name:="&FCR_TB_PRMPT_CALENDR_IMG,"html tag:=IMG","html id:="&sImgHtmlId,"index:=" & iIndex).exist

'Browser(sBrowserName).Page(sPageName).Image("file name:="&FCR_TB_PRMPT_CALENDR_IMG,"html tag:=IMG","html id:="&sImgHtmlId,"index:=" & iIndex).highlight
Call ImageClick_OR(sBrowserName,sPageName,sCalImage,iTestNo)
If false Then
If Browser(sBrowserName).Page(sPageName).Image("file name:="&FCR_TB_PRMPT_CALENDR_IMG,"html tag:=IMG","html id:="&sImgHtmlId,"index:=" & iIndex).Exist Then
Browser(sBrowserName).Page(sPageName).Image("file name:="&FCR_TB_PRMPT_CALENDR_IMG,"html tag:=IMG","html id:="&sImgHtmlId,"index:=" & iIndex).Click

Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the Image ", " Name ' " & sImgFileName & "' and clicked successfully." )


Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the Image ", " Name ' " & sImgFileName & "' not found to click." )


End If
End If
'Call ImageClick_NOR(sBrowserName,sPageName,sImgFileName,iTestNo)
'Call ImageClick(sBrowserName,sPageName,FCR_TB_PRMPT_CALENDR_IMG,FCR_NULL,iTestNo)
'Browser(sBrowserName).Page(sPageName).Image("file name:=calendar.jpg " , "html tag:=IMG").Click
'msgbox iYrDiff
If iYrDiff > cInt(FCR_ZERO) Then
'msgbox iYrDiff
For iYrCntr = 1 to iYrDiff
'Browser(sBrowserName).Page(sPageName).Image("file name:="&FCR_TB_PRMPT_CALENDR_PREVYR_IMG , "html tag:=IMG", "index:="&iIndex).Click
Call ImageClick_OR(sBrowserName,sPageName,sCalPrevYr,iTestNo)
Next
End if
If iYrDiff < cInt(FCR_ZERO) then
'msgbox iYrDiff & "Less than zerto"
For iCntr = 1 to abs( iYrDiff)
'Browser(sBrowserName).Page(sPageName).Image("file name:=nextyear.gif" , "html tag:=IMG", "index:="&iIndex).Click
Call ImageClick_OR(sBrowserName,sPageName, sCalNxtYr,iTestNo)
Next
End if
If iMonDiff > cInt(FCR_ZERO) Then
For iMonCntr = 1 to iMonDiff
'Browser(sBrowserName).Page(sPageName).Image("file name:="&FCR_TB_PRMPT_CALENDR_PREVMON_IMG , "html tag:=IMG", "index:=").Click
Call ImageClick_OR(sBrowserName,sPageName,sCalPrevMn,iTestNo)
Next
End if
if iMonDiff < cInt(FCR_ZERO) then
For iCntr = 1 to abs( iMonDiff)

'Msgbox Browser(sBrowserName).Page(sPageName).Image("file name:=nextmonth.gif","html tag:=IMG", "index:=").Exist
'Browser(sBrowserName).Page(sPageName).Image("file name:=nextmonth.gif","html tag:=IMG", "index:=").Click
Call ImageClick_OR(sBrowserName,sPageName, sCalNxtMn,iTestNo)
Next
End if
'Browser(sBrowserName).Page(sPageName).Link("html tag:=A", index:=","name:=" &sDateLinkName).Click
Call ClickLink(sBrowserName,sPageName, FCR_NULL, sDateLinkName,iDtIndx,iTestNo)

End Sub


Function GetLtstJobCode(sBrowserName,sPageName,sHtmlId,iTestNo)

If Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).Exist Then

iRowCnt = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).RowCount
'If sStr<>"" Then
If iRowCnt<> "" Then
sGetLatestCode = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).GetCellData(2,2)
Call GenerateTestStatus (iTestNo,FCR_PASS, "Get Latest JobCode from Table ", "Latest Jobcode '" & sGetLatestCode)
'Reporter.ReportEvent MicPass, "Get Latest JobCode from Table ", "Latest Jobcode '" & sGetLatestCode
GetLtstJobCode = sGetLatestCode
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Get Latest JobCode from Table ", "The table contains no rows to get latest job code. ")

Reporter.ReportEvent MicFAIL, "Get Latest JobCode from Table ", "The table contains no rows to get latest job code. "
GetLtstJobCode = "False"
'Reporter.ReportEvent MicFAIL, "Get Latest JobCode from Table ", "Latest Jobcode '" & sGetLatestCode & "' in table is not found."
End If
Else
Reporter.ReportEvent MicFAIL, "Get Latest JobCode from Table ", "The table with HtmlID '"&sHtmlId &"' is not found in the page. "
'Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).GetCellData(iRCnt,sStrCol)
End If

End Function


Sub SavePDFFile(sFileName,iTestNo)
hFrameHwnd = Window("regexpwndclass:=IEFrame", "index:=" & "*").GetROProperty("Hwnd")
'msgbox hFrameHwnd
If Browser("hwnd:=" & hFrameHwnd).Exist then
sOpenUrl = Browser("hwnd:=" & hFrameHwnd).GetROProperty("openurl")
'msgbox sOpenUrl
sOpenUrlArr = split(sOpenUrl,"?")
If Ubound(sOpenUrlArr) > 0 then
If Instr(1, sOpenUrlArr(1), "method=loadReport&fileName") <> 0 then
Set objShell=CreateObject("WScript.Shell")
Window("hwnd:="& hFrameHwnd).Activate
Wait(5)
objShell.SendKeys"%"+"F"
Wait(2)
objShell.SendKeys"F"
Wait(2)
objShell.SendKeys"A"
Wait(2)


if Browser("hwnd:="& hFrameHwnd).Dialog("regexpwndtitle:=Save a Copy...").WinEdit("nativeclass:=Edit","attached text:=File &name:").Exist then

Browser("hwnd:="& hFrameHwnd).Dialog("regexpwndtitle:=Save a Copy...").WinEdit("nativeclass:=Edit","attached text:=File &name:").set sFileName
wait 1
Browser("hwnd:="& hFrameHwnd).Dialog("regexpwndtitle:=Save a Copy...").WinButton("regexpwndtitle:=Save").Click
If Browser("hwnd:="& hFrameHwnd).Dialog("regexpwndtitle:=Save a Copy...").Dialog("regexpwndtitle:=Save As").Exist(1) Then
Browser("hwnd:="& hFrameHwnd).Dialog("regexpwndtitle:=Save a Copy...").Dialog("regexpwndtitle:=Save As").WinButton("regexpwndtitle:=&Yes").Click
'Reporter.ReportEvent MicPass,"To Save File Name", "File name:' "&sFileName& " is sucessfully saved in machine."
Call GenerateTestStatus(iTestNo, FCR_PASS, "To Save File Name", "File name:' "&sFileName& " is sucessfully saved in machine.")
Else
Call GenerateTestStatus(iTestNo, FCR_PASS, "To Save File Name", "File name:' "&sFileName& " is sucessfully saved in machine.")
End If
Else
'Reporter.ReportEvent MicFail,"To Save File Name", "WinEdit- 'File name:' is not found in dialog 'Save a Copy..'"
Call GenerateTestStatus(iTestNo, FCR_FAIL, "To Save File Name", "WinEdit- 'File name:' is not found in dialog 'Save a Copy..'")
End if

Set objShell = nothing
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "To Save File Name", "The File generate doesn't contain 'fileName=batchreport_*' in the page .' ")
End if
End If
Window("hwnd:="& hFrameHwnd).Close
End if
Set sOpenUrlArr = nothing
End Sub


Function CheckUnCheck_HtmlID(sBrowserName, sPageName, sHtmlId,iRow,iCol,iItr,sOperation,iTestNo)
' HELP
' method: CheckUnCheck_HtmlID()
' returns: None
' parameter: iRow, iCol as Row &Col
' parameter: sOperation as "ON/OFF"
' notes: * To check/uncheck the checkbox in a Table based on the HtmlId provided
' END
If Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).Exist Then
iRowCnt = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).RowCount
If iRowCnt > 1Then
if iItr <> "" then
iRowCnt = iItr
End if

'msgbox iRowCnt
For iRCnt = iRow to iRowCnt
SetCheckBoxexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).ChildItemCount(iRow, iCol, "WebCheckBox"))
If SetCheckBoxexist <> 0 Then
Set SetCheckBox = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).ChildItem(iRCnt,iCol, "WebCheckBox", 0)
SetCheckBox.Set sOperation
Call GenerateTestStatus(iTestNo, FCR_PASS, "CheckUnCheck","Check Box" & " in table at Row" & CStr(iRCnt) & ", Column " & CStr(iCol) & " is made "&sOperation&".")
'Reporter.ReportEvent MicPass, "Operate Check Box in Table ", sStr &" string found and Check Box" & " in table at Row" & CStr(iRCnt) & ", Column " & CStr(iCol) & " is made "&sOperation&"."
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "CheckUnCheck", "Check Box" & " in table at Row" & CStr(iRCnt) & ", Column " & CStr(iCol) & " is not found.")
'Reporter.ReportEvent MicFAIL, "Operate Check Box in Table ", "Check Box '" & sCheckBox & "' in table at Row" & CStr(iRCnt) & ", Column " & CStr(iCol) & " is made "&sOperation&"."
End If
Next
End if
CheckUnCheck_HtmlID = iRowCnt
Else
CheckUnCheck_HtmlID = 1
Call GenerateTestStatus(iTestNo, FCR_FAIL, "CheckUnCheck", "Table " & sHtmlId & "' is not found.")
End if
End Function

Sub ClickTableLink_HtmlID(sBrowserName,sPageName,sHtmlId, iRow, iCol,iTestNo)

' HELP
' method: ClickTableLink_HtmlID()
' returns: None
' parameter: iRow, iCol as Row &Col
' parameter:
' notes: * To click on Link in a Table based on the HtmlId provided
' END

Dim sLink, sLinkName
Browser(sBrowserName).Page(sPageName).sync

If Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).Exist Then
'Check required object is present in the specified cell
SetLinkexist = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).ChildItemCount(iRow, iCol, "Link")
If SetLinkexist <> 0 Then
sLinkName = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).GetCellData(iRow, iCol)
Set sLink = Browser(sBrowserName).Page(sPageName).WebTable("html id:="&sHtmlId).ChildItem(iRow, iCol, "Link", 0)
'Msgbox sLink.value
sLink.Click
Call GenerateTestStatus(iTestNo, FCR_PASS, "Click a Table Link" , "Sucessfully Clicked on Link : " & CStr(sLinkName)&"at row#"&iRow&"and column#"&iCol)
'Reporter.ReportEvent MicPass, "Click a Table Link" , "Sucessfully Clicked on Link : " & CStr(sLinkName)
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Click a Table Link", "Cell is Empty to clic Link : " & CStr(sLinkName)&"at row#"&iRow&"and column#"&iCol)
'Reporter.ReportEvent MicFail, "Click a Table Link" , "Cell is Empty to clic Link : " & CStr(sLinkName)
End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Click a Table Link", "Table " & sHtmlId & "' is not found.")
'Reporter.ReportEvent MicPass, "Click a Table Link" , "Table Doesn't Exist"

End If

Set sLink = Nothing

End Sub



Sub SaveCSVFile(sFileName,iTestNo)
hFrameHwnd = Window("regexpwndclass:=IEFrame", "index:=" & "*").GetROProperty("Hwnd")
'msgbox hFrameHwnd
'Browser("hwnd:=" & hFrameHwnd).Highlight
If Browser("hwnd:=" & hFrameHwnd).Exist then
sOpenUrl = Browser("hwnd:=" & hFrameHwnd).GetROProperty("openurl")
'msgbox sOpenUrl
sOpenUrlArr = split(sOpenUrl,"?")
If Ubound(sOpenUrlArr) > 0 then
If Instr(1, sOpenUrlArr(1), "method=loadReport&fileName") <> 0 then

If Browser("hwnd:=" & hFrameHwnd).Dialog("regexpwndtitle:=File Download").Exist Then
'Browser("hwnd:=" & hFrameHwnd).Dialog("regexpwndtitle:=File Download").Highlight
Browser("hwnd:=" & hFrameHwnd).Dialog("regexpwndtitle:=File Download").WinButton("regexpwndtitle:=&Save").Click

If Dialog("regexpwndtitle:=Microsoft Excel").Exist(1) then
Dialog("regexpwndtitle:=Microsoft Excel").WinButton("regexpwndtitle:=OK").Click
End if

If Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").Exist(1) Then
Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").WinEdit("nativeclass:=Edit","attached text:=File &name:").highlight
Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").WinEdit("nativeclass:=Edit","attached text:=File &name:").set sFileName
Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").WinButton("regexpwndtitle:=&Save").Click
if Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").Dialog("regexpwndtitle:=Save As").Exist(1) then
Dialog("regexpwndtitle:=File Download").Dialog("regexpwndtitle:=Save As").Dialog("regexpwndtitle:=Save As").WinButton("regexpwndtitle:=&Yes").Click
End if
wait 3
Dialog("regexpwndtitle:=Download complete").highlight
Dialog("regexpwndtitle:=Download complete").WinButton("regexpwndtitle:=Close").Click
Call GenerateTestStatus(iTestNo, FCR_PASS, "To Save File Name", "File name:' "&sFileName& " is sucessfully saved in machine.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "To Save File Name", "File name:' "&sFileName& " is sucessfully saved in machine.")
End If

Else
'Reporter.ReportEvent MicFail,"To Save File Name", "Dialog- 'File DownLoad' is not found in a page.'"
Call GenerateTestStatus(iTestNo, FCR_FAIL, "To Save File Name", "Dialog- 'File DownLoad' is not found in a page.")
End if


'Set objShell = nothing
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "To Save File Name", "The File generate doesn't contain 'method=loadReport&fileName' in the page .' ")
End if
End If
'Window("hwnd:="& hFrameHwnd).Close
End if
Set sOpenUrlArr = nothing
End Sub



Sub SaveHTMFile(sFileName,iTestNo)

hFrameHwnd = Window("regexpwndclass:=IEFrame", "index:=" & "*").GetROProperty("Hwnd")
'msgbox hFrameHwnd
'Browser("hwnd:=" & hFrameHwnd).Highlight
If Browser("hwnd:=" & hFrameHwnd).Exist then
sOpenUrl = Browser("hwnd:=" & hFrameHwnd).GetROProperty("openurl")
'msgbox sOpenUrl
sOpenUrlArr = split(sOpenUrl,"?")
If Ubound(sOpenUrlArr) > 0 then
If Instr(1, sOpenUrlArr(1), "method=loadReport&fileName") <> 0 then
Set objShell=CreateObject("WScript.Shell")
Window("hwnd:="& hFrameHwnd).Activate
Wait(5)
objShell.SendKeys"%"+"F"
Wait(2)
objShell.SendKeys"F"
Wait(2)
objShell.SendKeys"A"
Wait(2)
'dlgHwnd = Dialog("regexpwndtitle:=Save As").GetROProperty("Hwnd")
dlgHwnd = Browser("hwnd:=" & hFrameHwnd).Dialog("regexpwndtitle:=Save Web Page").GetROProperty("Hwnd")
If dlgHwnd <> "" Then

Browser("hwnd:=" & hFrameHwnd).Dialog("hwnd:="&dlgHwnd).WinEdit("nativeclass:=Edit","attached text:=File &name:").set sFileName
wait 1
Browser("hwnd:=" & hFrameHwnd).Dialog("hwnd:="&dlgHwnd).WinButton("regexpwndtitle:=&Save").HIGHLIGHT
Browser("hwnd:=" & hFrameHwnd).Dialog("hwnd:="&dlgHwnd).WinButton("regexpwndtitle:=&Save").Click
If Browser("hwnd:=" & hFrameHwnd).Dialog("hwnd:="&dlgHwnd).Dialog("regexpwndtitle:=Save Web Page").Exist(1) Then
Browser("hwnd:=" & hFrameHwnd).Dialog("hwnd:="&dlgHwnd).Dialog("regexpwndtitle:=Save Web Page").WinButton("regexpwndtitle:=&Yes").Click
wait 1
Call GenerateTestStatus(iTestNo, FCR_PASS, "To Save File Name", "File name:' "&sFileName& " is sucessfully saved in machine.")
Else
Call GenerateTestStatus(iTestNo, FCR_PASS, "To Save File Name", "File name:' "&sFileName& " is sucessfully saved in machine.")
End If
Else
'Reporter.ReportEvent MicFail,"To Save File Name", "WinEdit- 'File name:' is not found in dialog 'Save a Copy..'"
Call GenerateTestStatus(iTestNo, FCR_FAIL, "To Save File Name", "Dialog- 'Save Web Page' is not found in Page..")
End if

Set objShell = nothing
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "To Save File Name", "The File generate doesn't contain 'method=loadReport&fileName' in the page .' ")
End if
End If
Window("hwnd:="& hFrameHwnd).Close
End if
Set sOpenUrlArr = nothing
End Sub


'================================================================================================
' // Procedure FindFile will search the given file name by system date.
'================================================================================================
Public Sub FindFile (sBrowserName,sPageName,StrSavedFileName,IntRowCount,iTestNo) '// This Procedure will find the file name saved with system date.

For intLoop =2 to IntRowCount
StrFileName = Browser(sBrowserName).Page(sPageName).WebTable("Selection Criteria File").GetCellData(intLoop,1)

If trim(StrFileName) =StrSavedFileName Then '// 001 This if will check for the file name.
StrFileSavedDate =Browser(sBrowserName).Page(sPageName).WebTable("Selection Criteria File").GetCellData(intLoop,2)
If cdate(StrFileSavedDate)=Date Then '// 002 This if will check for the file saved date.

Call GenerateTestStatus(iTestNo, FCR_PASS, "FindFile", "File name:' "&StrSavedFileName& " is sucessfully saved with System Date.")
'Reporter.ReportEvent micPass,"verified","Pass"
Exit For
Else '// 002 This if will check for the file saved date else part.
Call GenerateTestStatus(iTestNo, FCR_PASS, "FindFile", "File name:' "&StrSavedFileName& " is Not saved with System Date.")
Reporter.ReportEvent micFail,"SystemDate","Failed"
End If '// 002 This if will check for the file saved date ends here.
End If '// 001 This if will check for the file name ends here.
Next
End Sub

Comments

Popular posts from this blog

Convert JSON to XML using QTP/UFT/VBScript

Sample Code : Dim strPage,strJSON,objIE strPage = "C:\Jay\JLoader.html" Set objIE = CreateObject("InternetExplorer.Application") objIE.Visible = True objIE.Navigate2 strPage While objIE.Busy : Wend strJSON = "{""FirstName"":""Jay"", ""LastName"":""Krishna""}" Set objWin = objIE.document.parentWindow objWin.execScript "var jsonStr2XML = function(strJSON) { return json2xml(JSON.parse(strJSON));};" Msgbox  oWin.jsonStr2XML(strJSON) objIE.Quit In Detail: Converting The most popular data interchange format JSON(JavaScript Object Notation) to XML using QTP/UFT. Parsing JSON in UFT could be a challenge so we will use JavaScript in UFT to make it perfect. SO We need :              Java Script API  - To Convert JSON to XML                         JavaScript Files :                         http://goessner.net/download/prj/jsonxml/j

Read Outlook mail attachment and Body using Vb Script or QTP

Set olApp = CreateObject("Outlook.Application") Set olns = olApp.GetNameSpace("MAPI") Set ObjFolder = olns.GetDefaultFolder(6) j = 0 For each item1 in ObjFolder.Items        iattachCnt = item1.Attachments.Count     Print "Attachments Count: " & iattachCnt     For i = 1 to iattachCnt         Print "FileName :    " & item1.Attachments(i).FileName         Print "Display Name:   " & item1.Attachments(i).DisplayName         Print "Size: " & item1.Attachments(i).Size     Next     Print " Body : " & item1.body     Print "--------------------------------------Mail Num - " & j & " -----------------------------------------------"     j = j+1    Next

Excel Sorting By Rows and Columns

Excel Sorting By Row: Const xlAscending = 1 Const xlNo = 2 Const xlSortRows = 2 Set objExcel = CreateObject(“Excel.Application”) objExcel.Visible = True Set objWorkbook = objExcel.Workbooks.Open(“C:\Jay\Docs1.xls”) Set objWorksheet = objWorkbook.Worksheets(1) objWorksheet.Cells(1,1).activate Set objRange = objExcel.ActiveCell.EntireRow objRange.Sort objRange, xlAscending, , , , , , xlNo, , , xlSortRows set objExcel=nothing Excel Sorting By Column : Const xlAscending = 1′represents the sorting type 1 for Ascending 2 for Desc Const xlYes = 1 Set objExcel = CreateObject(“Excel.Application”)’Create the excel object objExcel.Visible = True’Make excel visible Set objWorkbook = _ objExcel.Workbooks.Open(“C:\Jay\Docs1.xls”)’Open the document Set objWorksheet = objWorkbook.Worksheets(1)’select the sheet based on the index .. 1,2 ,3 … Set objRange = objWorksheet.UsedRange’which select the range of the cells has some data other than blank Set objRange2 = objExcel.Range

How to Read or Select Context Menu or Right Click Menu using QTP.

Select The Item in Right Click Menu or Context Menu: Window("sampleWindow").WinMenu("MenuObjType:=1).Select"File;New" Here MenuObjtype can be 1 r 2 r 3 .......n Check wether the Item is Exist or Not: If Window("sampleWindow").WinMenu("MenuObjType:=1).GetItemProperty("1","Exist") Then   Msgbox"Exist" Else  Msgbox"Does Not Exist" End If                                         Or If Window("sampleWindow").WinMenu("MenuObjType:=1).GetItemProperty("File","Exist") Then   Msgbox"Exist" Else  Msgbox"Does Not Exist" End If Get the Items in Context Menu: For i = 1 to 10 Print  Window("sampleWindow").WinMenu("MenuObjType:=" & i).GetItemProperty("1","Label") Then Next

How to Download a file using VbScript

Following is the code to download a file using Vbscript, without using QTP This code uses the HTMLDom and URLDownloadToFile method from urlmon API. Since VBScript does support calling Native API methods directly, here I am using  Excel macro to declare a function for the urlmon API and running the macro by Excel API from VBscript Step1: Create a new excel and open the visual basic editor, Insert Module and paste the following code the Module, save the excel file Private Declare Function URLDownloadToFile Lib “urlmon” Alias _                                            “URLDownloadToFileA” ( _                                            ByVal pCaller As Long, ByVal szURL As String, _                                            ByVal szFileName As String, _                                            ByVal dwReserved As Long, _                                            ByVal lpfnCB As Long) As Long Sub FileSave(strUrl, Des)     r = URLDownloadToFile(0, strUrl, Des, 0, a)