Skip to main content

Web Based Functions - I

Function InvokeApp(sBrowserType,sAppURL)
'HELP
'method :InvokeApp(sBrowserType,sAppURL)
'returns :None
'parameter:bLogin: Start from login or not, 1 means login
'parameter:aLoginData: Consists user name and password
'parameter:sBrowserType: Browser type i.e IE for Internet Explorer, NS for Netscape Navigator
'parameter:sObjectType: Object type to navigate
'parameter:sObjectNames: Object names to further navigate
'notes :This function is to login and clicks the provided object.
'End
Dim sObjectData
Dim iCount
'msgbox sAppURL
If ucase(sBrowserType) = "IE" Then
SystemUtil.Run "iexplore.exe",sAppURL
'ClickSecurityButton()
InvokeApp = "True"
Else
InvokeApp = "False"
End If
End Function


Sub TestSettings(sORPath,sORFileName)
Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Test.Settings.Run.StartIteration = 1
App.Test.Settings.Run.EndIteration = 1
App.Test.Settings.Resources.ObjectRepositoryPath = sORPath&sORFileName
App.Test.Settings.Run.ObjectSyncTimeOut = 20000
App.Test.Settings.Web.BrowserNavigationTimeout = 10000
Set App = Nothing
End Sub

Function LoginInfo(sPath,sShtSrcID,iRow)
' HELP
' Created : jai
' Created Date :08-08-07
' Modified Date:26-10-07
' method :LoginInfo()
' returns :Returns Array
' parameter :sPath,iRow
' notes :Returns Values from all the Columns based on specified row.
' END
Dim pCount,iCnt
ReDim Info(100)
DataTable.ImportSheet sPath,sShtSrcID,2
pCount = DataTable.GetSheet(2).GetParameterCount
DataTable.SetCurrentRow iRow
For iCnt = 1 to pCount
Info(iCnt-1) = DataTable.Value(iCnt,2)
Next
LoginInfo = Info
End Function


Function ModularInfo(sPath,sShtSrcID,iRow)
' HELP
' Created: jai
' Created Date: 08-08-07
' method: LoginInfo()
' returns: Returns Array
' parameter: sPath,iRow
' notes: Returns Values from all the Columns based on specified row.
' END
Dim pCount,iCnt
ReDim Info(100)
DataTable.ImportSheet sPath,sShtSrcID,2
pCount = DataTable.GetSheet(2).GetParameterCount
DataTable.SetCurrentRow iRow
For iCnt = 1 to pCount
Info(iCnt-1) = DataTable.Value(iCnt,2)
Next
ModularInfo = Info
End Function

Sub GenerateTestStatus (iTestNo, sStatus,sReportEventStepName, sDetails)
Dim sEventStatus
Dim sResPath
Select Case UCase(sStatus)
Case "PASS"
sEventStatus= micPass
Reporter.ReportEvent sEventStatus,sReportEventStepName,"TestCase ID: "& iTestNo& VbCrLf &sDetails
Case "FAIL"
sEventStatus= micFail
Reporter.ReportEvent sEventStatus,sReportEventStepName,"TestCase ID: "& iTestNo& VbCrLf &sDetails
ExitRun("Script failed due to unexpected behaviour of Application")
Case "DONE"
sEventStatus= micDone
Reporter.ReportEvent sEventStatus,sReportEventStepName,"TestCase ID: "& iTestNo& VbCrLf &sDetails
Case "WARNING"
sEventStatus= micWarning
Reporter.ReportEvent sEventStatus,sReportEventStepName,"TestCase ID: "& iTestNo& VbCrLf &sDetails
Case " "
sEventStatus= micWarning
Reporter.ReportEvent sEventStatus,sReportEventStepName,"TestCase ID: "& iTestNo& VbCrLf &sDetails
End Select
End Sub

Sub VerifyText(sBrowserName, sPageName, sTableName, sExpTitle,iTestNo)
' HELP
' method: VerifyText()
' returns: None
' parameter: sBrowserName sTableName: Name of Table
' 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
If Browser(sBrowserName).Page(sPageName).WebTable(sTableName).Exist Then
'msgbox Browser(sBrowserName).Page(sPageName).WebTable(sTableName).Exist
stext = Browser(sBrowserName).Page(sPageName).WebTable(sTableName).GetROProperty("innertext")
'msgbox stext & "is compared with" & sExpTitle
If InStr(LCase(stext), LCase(sExpTitle)) <> 0 Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify text in page", "'"& sExpTitle & "' successfully verified on the page '"&sPageName&"'." )
'Reporter.ReportEvent MicPass, "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." )
'Reporter.ReportEvent MicFail, "Verify text in page ", "" & sExpTitle & " doesn't exist."
End If
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify text in page", " Table '" & sTableName & "' doesn't exist." )
'Reporter.ReportEvent MicFail, "Verify text in page", " Table '" & sTableName & "' doesn't exist."
End If
End Sub

Function SelectData(sBrowserName, sPageName, sListName, sValue, iTestNo)
' HELP
' method: SelectData
' returns: None
' parameter: sListName,sValue
' notes: This will selects given value from the given list box
' END
Dim stext, bListItemFound, sDisplayedListItems, iItem, iItemsCount
bListItemFound = False
Browser(sBrowserName).Page(sPageName).sync
'MSgbox Browser(sBrowserName).Page(sPageName).WebList("name:=" & sListName, "html tag:=SELECT", "index:=" & iIndex).Exist
'check for the required weblist
If Browser(sBrowserName).Page(sPageName).WebList("name:=" & sListName, "html tag:=SELECT", "index:=" & iIndex).Exist Then
'check whether the weblist is in enabled state
If Browser(sBrowserName).Page(sPageName).WebList("name:=" & sListName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("disabled") = FCR_ZERO Then
'retrieve the items from the list
iItemsCount = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sListName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("items count")
'in the list
For iItem = 1 To iItemsCount
'get the list item present at iItem position
stext = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sListName, "html tag:=SELECT", "index:=" & iIndex).GetItem(iItem)
'stext1=UCase(Replace(stext," ",""))
'compare the value from the list with that of the user required
If Trim(stext) = Trim(sValue) Then
'select the required item
Browser(sBrowserName).Page(sPageName).WebList("name:=" & sListName, "html tag:=SELECT", "index:=" & iIndex).Select stext
'make necessary report event
Call GenerateTestStatus(iTestNo, FCR_PASS, "Select data from ComboList", " Name '" & sListName & "' exist and '" & sValue & "' data is selected successfully.")
bListItemFound = True
Exit For
End If
Next
Else 'if weblist is in disabled state
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Select data from ComboList", " Name '" & sListName & "' is not enabled to select.")
Exit Function
End If 'check for the weblist state
'if required item is not found in the list
If Not bListItemFound Then
sDisplayedListItems = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sListName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("all items")
'display available list items
Call GenerateTestStatus(iTestNo, FCR_DONE, "Select data from ComboList", "Items in the list '" & sListName & "' are '" & sDisplayedListItems & "'")
'make necessary report event
Call GenerateTestStatus(TestCase_ID, FCR_FAIL, "Select data from ComboList", "Combo List '" & sListName & "' exist and '" & sValue & "' is not available to select ")
End If 'check for the existence of the list item
Else 'if the list is not available
'make necessary report event
Call GenerateTestStatus(TestCase_ID, FCR_FAIL, "Select data from ComboList", "Combo List '" & sListName & "' doesn't exist to select '" & sValue & "'")
End If 'check for the weblist existence in the application
End Function

'CHK$$
Sub ClickTableLink(sBrowserName, sPageName, sInnertext, sRow, sCol,iTestNo)
' HELP
' method: ClickTableLink()
' returns:
' parameter: sRow,sCol : Row &Col ,sInnertext
' parameter:
' notes: To CLick the Link in the Table. Table is identified based on inner text but not on its anme
' END
Dim SetLink
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext&".*","index:=1").Exist Then
bLinkexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext&".*","index:=1").ChildItemCount(sRow, sCol, "Link"))
If bLinkexist = 1 Then
Set SetLink = Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext&".*","index:=1").ChildItem(sRow, sCol, "Link", 0)
SetLink.Click
SetLinkName = Browser(sBrowserName).Page(sPageName).WebTable("innertext:="&sInnertext&".*","index:=1").GetCellData(sRow, sCol)
Call GenerateTestStatus(iTestNo, FCR_PASS, "Click Link in a Table ", "Link '" & SetLinkName & "' in table at " & CStr(sRow) & ", Column " & CStr(sCol) & " is clicked Successfully .")
Else
Call GenerateTestStatus(iTestNo, FCR_WARNING, "Click Link in a Table ", "Link '" & SetLinkName & "' in table at " & CStr(sRow) & ", Column " & CStr(sCol) & " is not found.")
End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Click Link in a Table ", "Web Table '" & CStr(sTableName) & "' not found in a given Page :" & CStr(sPageName) & ".")
End If
End Sub

Sub ClickLink_OR(sBrowserName, sPageName, sFrame, sLink_Name,iTestNo)
' HELP
' method: ClickLink_OR
' returns: None
' parameter: sFrame,sLink_Name. 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.
' notes: The Link should be under the OR
' END
Browser(sBrowserName).Page(sPageName).sync
If Trim(sFrame) <> "" Then
If Browser(sBrowserName).Page(sPageName).frame(sFrame).Link(sLink_Name).Exist Then
Browser(sBrowserName).Page(sPageName).frame(sFrame).Link(sLink_Name).Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the link", " Name ' " & sLink_Name & "' found and clicked Sucessfully." )
Reporter.ReportEvent MicPass, "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." )
End If
Else
If Browser(sBrowserName).Page(sPageName).Link(sLink_Name).Exist Then
Browser(sBrowserName).Page(sPageName).Link(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 If
End Sub

Sub ClickButton(sBrowserName, sPageName, sButton_Name, iIndx,iTestNo)
' HELP
' method: ClickButton
' returns: None
' parameter: sType,sButton_Name,iIndx
' notes: It will clicks on the given button in the page/application.
' END
Browser(sBrowserName).Page(sPageName).sync
'Browser(sBrowserName).Page(sPageName).WebButton("html tag:=BUTTON", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).highlight
'Msgbox "Button:"&Browser(sBrowserName).Page(sPageName).WebButton("html tag:=BUTTON", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).Exist
If Browser(sBrowserName).Page(sPageName).WebButton("html tag:=BUTTON", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).Exist Then
Browser(sBrowserName).Page(sPageName).WebButton("html tag:=BUTTON", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the button", " Name ' " & sButton_Name & "' found and clicked Sucessfully." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the button", " Name ' " & sButton_Name & "' not found to click." )
End If
End Sub

Sub ClickWebElement(sBrowserName,sPageName,sWebElement_Name,iIndex,iTestNo) 'Check it once
' HELP
' method: ClickWebElement
' returns: None
' parameter: sWebElement_Name Name of the Web Element to Click
' notes: It will Clicks on the given WebElement in the page/application.
' END
Browser(sBrowserName).Page(sPageName).sync
' Msgbox Browser(sBrowserName).Page(sPageName).WebElement("html tag:=TD", "innertext:=" & sWebElement_Name,"index:= "&iIndex).Exist
If Browser(sBrowserName).Page(sPageName).WebElement("html tag:=TD", "innertext:=" & sWebElement_Name,"index:= "&iIndex).Exist Then
Browser(sBrowserName).Page(sPageName).WebElement("html tag:=TD", "innertext:=" & sWebElement_Name,"index:= "&iIndex).Click
Call GenerateTestStatus (iTestNo,FCR_PASS," Click on WebElement ","Name '" &sWebElement_Name &"' WebElement is clicked Sucessfully.")
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL," Click on WebElement ","Name '" &sWebElement_Name &"' not found to click.")
End If
End Sub
Sub ClickTableLink_OR(sBrowserName, sPageName, sTableName, sRow, sCol,iTestNo)
' HELP
' method: ClickTableLink()
' returns:
' parameter: sRow,sCol : Row &Col ,sInnertext
' parameter:
' notes: To CLick the Link in the Table. Table should be under OR.
' END
Dim SetLink
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebTable(sTableName).Exist Then
bLinkexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable(sTableName).ChildItemCount(sRow, sCol, "Link"))
If bLinkexist = 1 Then
Set SetLink = Browser(sBrowserName).Page(sPageName).WebTable(sTableName).ChildItem(sRow, sCol, "Link", 0)
SetLink.Click
SetLinkName = Browser(sBrowserName).Page(sPageName).WebTable(sTableName).GetCellData(sRow, sCol)
Call GenerateTestStatus(iTestNo, FCR_PASS, "Click Link in a Table ", "Link '" & SetLinkName & "' in table at " & CStr(sRow) & ", Column " & CStr(sCol) & " is clicked Successfully .")
Else
Call GenerateTestStatus(iTestNo, FCR_WARNING, "Click Link in a Table ", "Link '" & SetLinkName & "' in table at " & CStr(sRow) & ", Column " & CStr(sCol) & " is not found.")
End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Click Link in a Table ", "Web Table '" & CStr(sTableName) & "' not found in a given Page :" & CStr(sPageName) & ".")
End If
End Sub

Sub ClickButton_JL(sBrowserName, sPageName, sButton_Name, iIndx,iTestNo)
' HELP
' method: ClickButton
' returns: None
' parameter: sType,sButton_Name,iIndx
' notes: It will clicks on the given button in the page/application.
' END
Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).sync
'Msgbox "Button:"&Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).WebButton("html tag:=BUTTON", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).Exist
If Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).WebButton("html tag:=BUTTON", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).Exist Then
Browser("creationtime:=1","name:="&sBrowserName).Page("title:="&sPageName).WebButton("html tag:=BUTTON", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the button", " Name ' " & sButton_Name & "' found and clicked Sucessfully." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the button", " Name ' " & sButton_Name & "' not found to click." )
End If
End Sub

Function ObjectExists(sBrowserName, sPageName, sObjectName, sObjectType,iTestNo)
' HELP
' method: ObjectExists()
' returns: Pass/Fail of the execution(0/1).
' parameter: sObjectName: Name of the object which to be verified.
' parameter: sObjectType: Type of the object can be verified are :-
'"WebElement","WebButton","WebEdit","WebList",'"Link","Image","WebButton","WebCheck","WebRadio"
' notes: This function verifies whether passed object as input is found or not.
' END
Dim sTitle
Select Case sObjectType
Case "WebElement":
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebElement(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
'Reporter.ReportEvent MicPass, "Verified Object ", " Test ID " & sTestID & "-" & sObjectType & "Name and Type " & sObjectName & " " & sObjectType & vbCrLf & " is existed in the correct location."
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "WebButton":
Browser(sBrowserName).Page(sPageName).sync
'msgbox Browser(sBrowserName).Page(sPageName).Exist
'msgbox Browser(sBrowserName).Page(sPageName).WebButton("html tag:=BUTTON", "name:=" & sObjectName, "type:=button", "index:=" & iIndex).Exist
If Browser(sBrowserName).Page(sPageName).WebButton("html tag:=BUTTON", "name:=" & sObjectName, "type:=button", "index:=" & iIndex).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "WebRadioGroup":
Dim iWebRadioButtonGroupItems
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebRadioGroup("html tag:=INPUT", "name:=" & sObjectName, "index:=" & iIndex).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "WebCheckBox":
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebCheckBox("index:=" & iIndex, "name:=" & sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "WebEdit":
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebEdit("name:=" & sObjectName, "type:=text", "index:=" & iIndex).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "Link":
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).Link("html tag:=A", "text:=" & sObjectName, "index:=" & iIndex).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "WebList":
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebList("name:=" & sObjectName, "html tag:=SELECT", "index:=" & iIndex).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "Image":
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).Image(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "WebTable":
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebTable(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "Browser":
If Browser(sBrowserName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
Case "WinButton":
If Browser(sBrowserName).Dialog(sPageName).WinButton("text:=" & sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
ObjectExists = "True"
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
ObjectExists = "False"
End If
End Select
End Function

Sub ClickLink(sBrowserName, sPageName, sFrame, sLink_Name, iIndexLink,iTestNo)
' HELP
' method: ClickLink
' returns: None
' parameter: sFrame,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(sBrowserName).Page(sPageName).sync
If Trim(sFrame) <> "" Then
If Browser(sBrowserName).Page(sPageName).frame(sFrame).Link("html tag:=A", "text:=" & sLink_Name, "index:=" & iIndexLink).Exist Then
Browser(sBrowserName).Page(sPageName).frame(sFrame).Link("html tag:=A", "text:=" & sLink_Name, "index:=" & iIndexLink).Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the link", " Name ' " & sLink_Name & "' found and clicked Sucessfully." )
Reporter.ReportEvent MicPass, "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." )
End If
Else
'Browser(sBrowserName).Page(sPageName).Link("html tag:=A", "index:=" & iIndexLink, "name:=" & sLink_Name).Highlight
'msgbox Browser(sBrowserName).Page(sPageName).Link("html tag:=A", "index:=" & iIndexLink, "name:=" & sLink_Name).Exist
If Browser(sBrowserName).Page(sPageName).Link("html tag:=A", "index:=" & iIndexLink, "name:=" & sLink_Name).Exist Then
Browser(sBrowserName).Page(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 If
End Sub

'CHK$$
Sub ClickButtonInFrame(sBrowserName, sPageName, sFrame, sButton_Name, iIndx,iTestNo)
' HELP
' method: ClickButtonInFrame
' returns: none
' parameter: sFrame,sButton_Name,iIndx
' notes: It will clicks on the given button in the page/application.
' END
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).frame(sFrame).WebButton("html tag:=INPUT", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).Exist Then
Browser(sBrowserName).Page(sPageName).sync
Browser(sBrowserName).Page(sPageName).frame(sFrame).WebButton("html tag:=INPUT", "name:=" & sButton_Name, "type:=button", "index:=" & iIndx).Click
Call GenerateTestStatus (iTestNo,FCR_PASS, "Click on the button in the frame ", " Name ' " & sButton_Name & "' and clicked successfully." )
'Reporter.ReportEvent MicPass, "Click on the button in the frame '", sButton_Name & "' and clicked successfully."
Browser(sBrowserName).Page(sPageName).sync
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Click on the button in the frame ", " Name ' " & sButton_Name & "' not found to click." )
'Reporter.ReportEvent MicFail, "Click on the button in the frame '", sButton_Name & "' not found to click."
End If
End Sub

Sub ImageLinkClick(sBrowserName, sPageName, sImgFileName, iIndex,iTestNo)
' HELP
' method: ImageLinkClick
' returns: None
' parameter: sImgName, iIndex
' notes: This will clicks on the given image link in the page/application.' END
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).Image("file name:= " & sImgFileName, "html tag:=IMG","image type:=Image Link", "index:="&iIndex).Exist Then
Browser(sBrowserName).Page("Journal Listing").Image("file name:= " & sImgFileName,"html tag:=IMG","image type:=Image Link", "index:="&iIndex).Highlight
Browser(sBrowserName).Page(sPageName).Image("file name:= " & sImgFileName, "html tag:=IMG","image type:=Image Link", "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 Sub

Sub ImageClick(sBrowserName, sPageName, sImgFileName, iIndex,iTestNo)
' HELP
' method: ImageClick
' returns: None
' parameter: sImgName, iIndex
' notes: This will clicks on the given image link in the page/application.
' END
Browser(sBrowserName).Page(sPageName).sync
Browser(sBrowserName).Page(sPageName).Image("file name:= " & sImgFileName, "html tag:=IMG", "index:=" & iIndex).Highlight
If Browser(sBrowserName).Page(sPageName).Image("file name:= " & sImgFileName, "html tag:=IMG", "index:=" & iIndex).Exist Then
Browser(sBrowserName).Page(sPageName).Image("file name:= " & sImgFileName, "html tag:=IMG", "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 Sub

Sub EnterData(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 sEdName&" "&Browser(sBrowserName).Page(sPageName).WebEdit("name:="& sEdName,"index:=" & iIndex).Exist
If Browser(sBrowserName).Page(sPageName).WebEdit("name:=" & sEdName,"index:=" & iIndex).Exist(1) Then
Browser(sBrowserName).Page(sPageName).WebEdit("name:=" & sEdName, "index:=" & iIndex).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 OperateCheckBox(sBrowserName, sPageName, sControlName, sOptValue,iTestNo)
' HELP
' method: OperateCheckBox(sControlName,sDataValue)
' returns: None
' parameter: sControlName is name of the control
' parameter: sDataValue is Value that needs to be selected the radio button
' notes: Selection Check box is option made ON/OFF.
' END
Browser(sBrowserName).Page(sPageName).sync
'msgbox Browser(sBrowserName).Page(sPageName).WebCheckBox(sControlName).Exist
If Browser(sBrowserName).Page(sPageName).WebCheckBox(sControlName).Exist Then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Operate CheckBox", " Name '" & sControlName & "'check box exists.")
Browser(sBrowserName).Page(sPageName).WebCheckBox(sControlName).Set sOptValue
If sOptValue = "ON" Then
Call GenerateTestStatus(iTestNo, FCR_PASS, "Operate CheckBox", " Name '" & sControlName & "' Selection Check box is option made ON.")
Else
Call GenerateTestStatus(iTestNo, FCR_PASS, "Operate CheckBox", " Name '" & sControlName & "' Selection Check box is option made OFF.")
End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Operate CheckBox", " Name '" & sControlName & "' check box doesn't exists.")
End If
End Sub

Sub SelectRadioButton(sBrowserName, sPageName, sName, iOption,iTestNo)
' HELP
' method: SelectRadioButton
' returns: None
' parameter: sName as name of the WebRadio Group
' parameter: iOption as name of Radiobutton/option
' notes: It will selects radio button in Radiogroup .
' END
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebRadioGroup("html tag:=INPUT", "name:=" & sName, "index:=" & iIndex).Exist Then
Browser(sBrowserName).Page(sPageName).WebRadioGroup("html tag:=INPUT", "name:=" & sName, "index:=" & iIndex).Select iOption
Call GenerateTestStatus(iTestNo, FCR_PASS, "Select Radio Button", " Name '" & sName & "' is exist and option "&iOption &" is selected.")
Browser(sBrowserName).Page(sPageName).sync
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Select Radio Button", " Name '" & sName & "' not found to select.")
End If
End Sub

Sub CloseAllBrowsers(sBrowser,iTestNo)
' HELP
' class: clsCommonFunctions
' method: CloseAllBrowsers (sBrowser)
' returns: None
' parameter: sBrowser: Name of the Browser
' notes: Close all browser instances
' End
Dim iCtr
Dim bFlag
Dim hFrameHwnd
Dim hLastHwnd
Dim dtHandles
Dim sFramename

'HWId= Window("regexpwndclass:=IEFrame","index:=*").GetROProperty("Hwnd")
'msgbox Browser("hwnd:="& HWId).Dialog("regexpwndtitle:=Microsoft Internet Explorer","index:=*").Highlight
hFrameHwnd = Window("regexpwndclass:=IEFrame","index:=*").GetROProperty("Hwnd")
'msgbox Browser("Hwnd:="& hFrameHwnd).Dialog("regexpwndtitle:=Microsoft Internet Explorer","index:=*").Exist
if Browser("Hwnd:="& hFrameHwnd).Dialog("regexpwndtitle:=Microsoft Internet Explorer","index:=*").Exist(1) then
'Browser("Hwnd:="& hFrameHwnd,"index:=*").Dialog("text:=Microsoft Internet Explorer").highlight
Browser("Hwnd:="& hFrameHwnd).Dialog("regexpwndtitle:=Microsoft Internet Explorer","index:=*").Close
End if
'if false then '*** remove the block later
If UCase(sBrowser) = "IE" Then
sFramename = "IEFrame"
Else
sFramename = "MozillaWindowClass"
End If
iCtr = 0
bFlag = 1
Set dtHandles = CreateObject("Scripting.Dictionary")
While (Window("regexpwndclass:=" & sFramename, "index:=" & iCtr).Exist And bFlag)
Wait 1
hFrameHwnd = Window("regexpwndclass:=" & sFramename, "index:=" & iCtr).GetROProperty("Hwnd")
If (hLastHwnd = hFrameHwnd) Then
bFlag = 0
Else
dtHandles.Add CStr(dtHandles.Count), hFrameHwnd
iCtr = iCtr + 1
End If
hLastHwnd = hFrameHwnd
Wend
For iCtr = 0 To dtHandles.Count - 1
hFrameHwnd = dtHandles.Item(CStr(iCtr))
If not strcomp(Window("regexpwndclass:="& sFramename, "index:=" & iCtr).GetROProperty("name"),"Welcome to Verizon Conferencing") = 0 then
'Window("regexpwndclass:="& sFramename, "index:=" & iCtr).highlight
'msgbox Window("regexpwndclass:="& sFramename, "index:=" & iCtr).GetROProperty("name")
Window("hwnd:=" & hFrameHwnd).Close
Else
'msgbox Window("regexpwndclass:="& sFramename, "index:=" & iCtr).GetROProperty("name")
End if
'Window("hwnd:=" & hFrameHwnd).Close
'End If
Next
'End if '*** remove the block later
End Sub

Function FrameObjectExists(sBrowserName, sPageName, sObjectName, sObjectType, sFramename,iTestNo)
' HELP
' method: ObjectExists(sObjectName,sObjectType)
' returns: Pass/Fail of the execution(0/1).
' parameter: sObjectName: Name of the object which to be verified.
' parameter: sObjectType: Type of the object can be verified are :-
'"WebElement","WebButton","WebEdit","WebList",'"Link","Image","WebButton","WebCheck","WebRadio"
' notes: This function verifies whether passed object as input is found or not in frame.
' END
Dim sTitle
Browser(sBrowserName).Page(sPageName).sync
Select Case sObjectType
Case "WebElement":
If Browser(sBrowserName).Page(sPageName).frame(sFramename).WebElement(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
Reporter.ReportEvent MicPass, "Object in the frame ", "The " & sObjectName & " " & sObjectType & " is existed."
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
End If
Case "WebRadioGroup":
If Browser(sBrowserName).Page(sPageName).frame(sFramename).WebRadioGroup(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
End If
Case "WebCheckBox":
If Browser(sBrowserName).Page(sPageName).frame(sFramename).WebCheckBox(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
End If
Case "WebEdit":
If Browser(sBrowserName).Page(sPageName).frame(sFramename).WebEdit(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
End If
Case "Link":
If Browser(sBrowserName).Page(sPageName).frame(sFramename).Link("html tag:=A", "text:=" & sObjectName, "index:=" & iIndex).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
End If
Case "WebList":
If Browser(sBrowserName).Page(sPageName).frame(sFramename).WebList(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
End If
Case "Image":
If Browser(sBrowserName).Page(sPageName).frame(sFramename).Image(sObjectName).Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
End If
Case "WebButton":
If Browser(sBrowserName).Page(sPageName).frame(sFramename).WebButton("html tag:=INPUT", "name:=" & sObjectName, "type:=button").Exist Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is existed." )
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Object in Frame ", "Name'" & sObjectName & "' and type '" & sObjectType & "' is not existed." )
End If
End Select
End Function

'CHK$$
Function IsAlphaNumeric(sString,iTestNo)
' HELP
' method: IsAlphaNumeric()
' returns: True/False of the execution
' parameter: sString as a String to Check the Data Type
' notes: Verifies whether String is an AlphaNumeric Type or not.
' END
Dim iString, sStringWord, regEx, Matches
If sString = "" Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "No Value to Verify Data Type", "as a Alpha Numeric Number." )
Else
For iString = 1 To Len(sString)
sStringWord = Mid(sString, iString, 1)
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.Pattern = "[A-Z][a-z][0-9]"
Set Matches = regEx.Execute(sStringWord)
If Matches.Count = 0 Then
IsAlphaNumeric = False
Set Matches = Nothing
Set regEx = Nothing
Call GenerateTestStatus (iTestNo,FCR_FAIL, " Value : " & CStr(sString), "not a Alpha Numeric Number." )
Exit Function
End If
IsAlphaNumeric = True
Set Matches = Nothing
Set regEx = Nothing
Next
Call GenerateTestStatus (iTestNo,FCR_PASS, " Value : " & CStr(sString), "is an Alpha Numeric Number." )
End If
End Function

Function GetWebListItems(sBrowserName, sPageName, sWebListName,iTestNo)
' HELP
' method: GetWebListItems()
' returns: All the WebList Items
' parameter: sWebListName : Name of the WebEdit to read All Items
' notes: This is used to display items of a Web List in Page
' END
Dim iWebListItemsCount
Dim iItem
Dim sSelectedItem
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebList("name:=" & sWebListName, "html tag:=SELECT", "index:=" & iIndex).Exist Then
'Browser(sBrowserName).Page(sPageName).WebList("name:="&sWebListName ,"html tag:=SELECT","index:="&iIndex).Select 0
iWebListItemsCount = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sWebListName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("items count")
sWebListAllitems = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sWebListName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("all items")
For iItem = 0 To iWebListItemsCount - 1
aWebListArray = Split(sWebListAllitems, ";")
sAllitems = Join(aWebListArray)
Call GenerateTestStatus (iTestNo,FCR_PASS, "Get WebListItems ", "Name'" & CStr(sWebListName) & "' Contains " & CStr(iWebListItemsCount) & " Items and " & " Items in Web List are : " & CStr(sAllitems)&"." )
Reporter.ReportEvent MicPass, " Web List: " & CStr(sWebListName) & " Contains " & CStr(iWebListItemsCount) & " Items ", " Items in Web List are : " & CStr(sAllitems)
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Get WebListItems ", "Name'" & CStr(sWebListName) & "' Contains " & CStr(iWebListItemsCount) & " Items and " & " Items in Web List are not Found in Web List." )
GetWebListItems = sWebListAllitems
Next
End If
End Function

'CHK$$
Function IsNumericValue(sNumericValue)
' HELP
' method: IsNumericValue(sNumericValue)
' returns: True/False of the execution
' parameter: sNumericValue: String to Check the Data Type
' notes: Verifies whether String is an Numeric Type or not.
' END
Dim iString, sStringWord, regEx, Matches
If sString = "" Then
Reporter.ReportEvent MicPass, "No Value to Verify Data Type", "as a Numeric Number"
Else
For iString = 1 To Len(sNumericValue)
sStringWord = Mid(sNumericValue, iString, 1)
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.Pattern = "[0-9]"
Set Matches = regEx.Execute(sStringWord)
If Matches.Count = 0 Then
IsNumericValue = False
Set Matches = Nothing
Set regEx = Nothing
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Data Type: ", "'"& CStr(sNumericValue) &"' is a Not a Numeric Value.")
Exit Function
End If
IsNumericValue = True
Set Matches = Nothing
Set regEx = Nothing
Next
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Data Type: ", "'"& CStr(sNumericValue) &"' is a Numeric Value.")
End If
End Function

Function GetWebEditContent(sBrowserName, sPageName, sWebEditName,iTestNo)
' HELP
' method: GetWebEditContent()
' returns: Run time WebEdit's Value
' parameter: sWebEditName as name of the WebEdit
' notes: This is used to get the Run time WebEdit's Value
' END
Dim sWebEditValue
If Browser(sBrowserName).Page(sPageName).WebEdit("type:=text", "name:=" & sWebEditName, "html tag:=INPUT", "index:=" & iIndex).Exist Then
sWebEditValue = Browser(sBrowserName).Page(sPageName).WebEdit("type:=text", "name:=" & sWebEditName, "html tag:=INPUT", "index:=" & iIndex).GetROProperty("Value")
GetWebEditContent = sWebEditValue
Call GenerateTestStatus (iTestNo,FCR_PASS, "Get WebEditContent: ", "Name '" &sWebEditName &"' Value Existed is: "& GetWebEditContent)
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Get WebEditContent: ", "Name '" &sWebEditName &"'does not Exists.")
End If
End Function

Sub VerifyWebEditContent(sBrowserName, sPageName, sWebEditName, sWebEditValue,iTestNo)
' HELP
' method: VerifyWebEditContent()
' returns: None
' other methods: GetWebEditContent() is used to execute
' parameter: sWebEditName as name of the WebEdit to Verify
' parameter: sWebEditValue as expected value of the WebEdit to Verify
' notes: This is used to Verify Data of Web Edit
' END
Dim sWebEditContent
Browser(sBrowserName).Page(sPageName).sync
sWebEditContent = GetWebEditContent(sBrowserName, sPageName, sWebEditName)
If (sWebEditContent <> "") Then
If (Trim(sWebEditContent) = Trim(sWebEditValue)) Then
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify Web Edit Contents ", "In WebEdit '"& sWebEditName &"' Expected value '"& sWebEditValue &"' is matched with Actual value '" &sWebEditContent &"'.")
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Web Edit Contents ", "In WebEdit '"& sWebEditName &"' Expected value '"& sWebEditValue &"' is not matched with Actual value '" &sWebEditContent &"'.")
End If
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Web Edit Contents ", "In WebEdit '"& sWebEditName &"' the values are empty to compare .")
End If
End Sub

Sub VerifyWebEditLength(sBrowserName, sPageName, sObjectName, sWebEditValue,iTestNo)
' HELP
' method: VerifyWebEditLength()
' returns: None
' parameter: sObjectName as name of the WebEdit to Verify and Set
' parameter: sWebEditValue : Value of the WebEdit to Verify and Set
' notes: This is used to Verify Data of Web Edit and Set Data
' END
Dim MyObjectExists
Dim iWebEditLength
Dim sCurrentValueofWebEdit
If Browser(sBrowserName).Page(sPageName).WebEdit("name:=" & sObjectName, "html tag:=INPUT", "type:=text", "index:=" & iIndex).Exist Then

iWebEditLength = Browser(sBrowserName).Page(sPageName).WebEdit("name:=" & sObjectName, "html tag:=INPUT", "type:=text", "index:=" & iIndex).GetROProperty("max length")

If (Len(sWebEditValue) > iWebEditLength) Then
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify Web Edit Contents ", "In WebEdit '"& sWebEditName &"' the values are empty to compare .")

Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify WebEdit Length ", "In WebEdit '"& sObjectName &"' we can't set the Value : " & CStr(sWebEditValue) &" Exceeding the Max Length of Object.")

Else
'It will set the data if the range is under the Edit Length
Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify WebEdit Length ", "In WebEdit '"& sObjectName &"' we can set the Value : " & CStr(sWebEditValue) &" and the value is with in the Limit.")

EnterData sBrowserName, sPageName, sObjectName, sWebEditValue
End If
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Verify WebEdit Length ", "In WebEdit '"& sObjectName &"' doesn't Exists to check.")

End If
End Sub


Sub VerifyWebListDefaultValue(sBrowserName, sPageName, sWebListName, sString,iTestNo)

' HELP
' method: VerifyWebListDefaultValue(sBrowserName,sPageName,sWebListName,sString)
' returns: None
' parameter: sWebListName as Name of the WebEdit to Verify the Default Value
' parameter: sString as Value of the WebEdit to Verify Default item
' notes: This is used to Verify 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 = VerifyWebListState(sBrowserName, sPageName, sWebListName)
If (sWebListState = 0) Then
sDefaultValue = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sWebListName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("Value")
If sDefaultValue <> "" Then
sDefaultValue = Replace(sDefaultValue, " ", "")
sString = Replace(sString, " ", "")
If InStr(Trim(LCase(sDefaultValue)), Trim(LCase(sString))) <> 0 Then

Call GenerateTestStatus (iTestNo,FCR_PASS, "Verify default value in Web List ", "The default value from application " & CStr(sDefaultValue) &" is matching with the expected default string " & CStr(sString)&".")

Else
Call GenerateTestStatus (iTestNo,FCR_FAIL,"Verify default value in Web List ", "The default value from application " & CStr(sDefaultValue) &" is not matching with the expected default string " & CStr(sString)&".")

End If
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL,"Verify Web List Value ", "No items in Web List '" & CStr(sWebListName)&"' to check.")
'Reporter.ReportEvent MicPass, "Verify Web List Value ", "No items in Web List : : " & CStr(sWebListName)
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 Sub

'CHK$$
Sub ClickWebAreaImage(sBrowserName, sPageName, sImgName,iTestNo)

' HELP
' method: ClickWebAreaImage
' returns: None
' parameter: sImgName
' notes: This will clicks on the given image link in the page/application.
' END
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebArea("alt:= " & sImgName, "html tag:=IMG").Exist Then
Browser(sBrowserName).Page(sPageName).WebArea("alt:= " & sImgName, "html tag:=IMG").Click

Call GenerateTestStatus (iTestNo,FCR_PASS, "Image Click ","Name '" & CStr(sImgName)&"' is clicked.")

Browser(sBrowserName).Page(sPageName).sync
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Image Click ","Name '" & CStr(sImgName)&"' is not found to click.")

End If

End Sub




Function GetErrorMessages(sBrowserName, sDialogBox,iTestNo)

' HELP
' method: GetErrorMessages(sBrowserName,sDialogBox)
' returns: Returns the Error Message from Application
' parameter: sBrowserName,sDialogBox
' notes: Returns Error Message to retrieve from specified Dialog
' END

Dim sErrorMessage

If Browser(sBrowserName).Dialog(sDialogBox).Exist then
sErrorMessage = Trim(Browser(sBrowserName).Dialog(sDialogBox).GetVisibleText())
If sErrorMessage <> "" Then
Call GenerateTestStatus (iTestNo,FCR_PASS,"Get ErrorMessages from Application","Name '" &sDialogBox &"' contains Message :" & CStr(sErrorMessage)&".")

Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Get ErrorMessages from Application","Name '" &sDialogBox &"'No Message to retrieve from specified Dialog.")

End If
GetErrorMessages = sErrorMessage
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL, "Get ErrorMessages from Application","Name '" &sDialogBox &"'no specified Dialog box in the Page '"&sBrowserName&"' .")
End If
End Function




Function VerifyErrorMessages(sBrowserName, sDialogBox, sMessage,iTestNo)

' HELP
' method: VerifyErrorMessages()
' other methods: GetErrorMessages() is used to execute
' returns: None
' parameter: sBrowserName,sMessage
' notes: Verifies the Error Message with Application Error Message
' END

Dim sReadMessage

sReadMessage = GetErrorMessages(sBrowserName, sDialogBox,iTestNo)

If InStr(sMessage, ReadMessage) <> 0 Then
VerifyErrorMessages = "True"
Call GenerateTestStatus (iTestNo,FCR_PASS," Verify the Error Messages ","Name '" &sDialogBox &"' having the message "&sReadMessage &"' is matching with the expected Message '" & CStr(sMessage)&"'.")

Else
VerifyErrorMessages = "False"
Call GenerateTestStatus (iTestNo,FCR_FAIL," Verify the Error Messages ","Name '" &sDialogBox &"' having the message "&sReadMessage &"' is not matching with the expected Message '" & CStr(sMessage)&"'.")

End If

End Function





Sub VerifyWebEditState(sBrowserName, sPageName, sWebEditName, iIndex,iTestNo)

' HELP
' method: VerifyWebEditState()
' notes: This is to retrieve the Disabled Property of an Web Edit Based on Index
' parameter: sWebEditName as Name of the Web Edit ,iIndex : Number of the WEeb Edit in Page
' END

Dim sWebWebEditState
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebEdit("name:=" & sWebEditName, "html tag:=INPUT", "index:=" & iIndex).Exist then

sWebWebEditState = Browser(sBrowserName).Page(sPageName).WebEdit("name:=" & sWebEditName, "html tag:=INPUT", "index:=" & iIndex).GetROProperty("disabled")
If (Trim(sWebWebEditState) = 0) Then
Call GenerateTestStatus (iTestNo,FCR_PASS," Check WebEdit State ","Name '" &sWebEditName &"' is in enabled State.")

Else
Call GenerateTestStatus (iTestNo,FCR_FAIL," Check WebEdit State ","Name '" &sWebEditName &"' is in disabled State.")

End If
Else

Call GenerateTestStatus (iTestNo,FCR_FAIL," Check WebEdit State ","Name '" &sWebEditName &"' doesn't exists.")
End If
End Sub


Sub VerifyRadiobuttonState(sBrowserName, sPageName, sWebRadioGroupName, sWebRadioButtonName,iIndex,iTestNo)

' HELP
' method: VerifySelectedRadiobutton()
' notes: This is to Verify the Name of the Radio Button Seleted or Not Selected
' parameter: sWebRadioGroupName as name of the Web Radio Group ,sWebRadioButtonName as name of the Radio Button to Verify
' END

Dim sSelectedWebRadioButtonName

Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebRadioGroup("html tag:=INPUT", "name:=" & sWebRadioGroupName,"index:=&iIndex").Exist Then

sSelectedWebRadioButtonName = Browser(sBrowserName).Page(sPageName).WebRadioGroup("html tag:=INPUT", "name:=" & sWebRadioGroupName,"index:=&iIndex").GetROProperty("Value")

If StrComp(sSelectedWebRadioButtonName, sWebRadioButtonName) = 0 Then
Call GenerateTestStatus (iTestNo,FCR_PASS," Check RadioButton State ","Name '" &sWebRadioButtonName &"'is selected .")

Else
Call GenerateTestStatus (iTestNo,FCR_PASS," Check RadioButton State ","Name '" &sWebRadioButtonName &"'is selected .")
Reporter.ReportEvent MicFail, " Verification of a NoN Selected Web Radio Button", "Name of the radio button Not Selected is :" & CStr(sWebRadioButtonName)
End If
Else
Call GenerateTestStatus (iTestNo,FCR_FAIL," Check RadioButton State ","Name '" &sWebRadioButtonName &"'doesn't exist.")

End If

End Sub







Sub ClickTableDataLink(sBrowserName,sPageName,sTableName, sRow, sCol,iTestNo)

' HELP
' method: ClickTableDataLink()
' returns: None
' parameter: sRow,sCol as Row &Col
' parameter:
' notes: * To click on Link in a Table
' END

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

If Browser(sBrowserName).Page(sPageName).WebTable(sTableName).Exist Then
'Check required object is present in the specified cell
sLinkName = GetCellData(sBrowserName, sPageName, sTableName, sRow, sCol,iTestNo)
If Browser(sBrowserName).Page(sPageName).WebTable(sTableName).ChildItem(sRow, sCol, GM_LINK, GM_ZERO).Exist Then

Set sLink = Browser(sBrowserName).Page(sPageName).WebTable(sTableName).ChildItem(sRow, sCol, GM_LINK, GM_ZERO)
If sLinkName <> "" Then
sLink.Click
Reporter.ReportEvent MicPass, "Click a Table Link" & CStr(sTableName), "Sucessfully Clicked on Link : " & CStr(sLinkName)
Else
Reporter.ReportEvent MicFail, "Click a Table Link" & CStr(sTableName), "Cell is Empty to clic Link : " & CStr(sLinkName)
End If
Else
Reporter.ReportEvent MicFail,"Click a Table Link"&Cstr(sTableName),"Link '"&Cstr(sLinkName)&"' Doesnot exist in the Row: '"&sRow&"' Column: '"&sCol
End If
Else
Reporter.ReportEvent MicPass, "Click a Table Link" & CStr(sTableName), "Table Doesn't Exist"

End If

Set sLink = Nothing

End Sub


Sub VerifyTableTextNotNull(sBrowserName, sPageName, sTableName, sRow, sCol,iTestNo)

' HELP
' method: VerifyTableTextNotNull(sBrowserName,sPageName,sTableName,sRow,sCol)
' returns:
' parameter: sBrowserName,sPageName,sTableName,sRow,sCol
' parameter:
' notes: Verifies Data from a Specific Cell of the table is present or not
' END

Dim sCellData
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebTable(sTableName).Exist Then
sCellData = GetCellData(sBrowserName, sPageName, sTableName, sRow, sCol,iTestNo)
If Trim(sCellData) <> "" Then

Else
Reporter.ReportEvent MicPass, " Cell Data of Table : " & CStr(sTableName), " there is No Value in Cell " & CStr(sRow) & " ::" & CStr(sCol)
End If
Else
Reporter.ReportEvent MicFail, "Verify Page Name", sTableName & " doesn't exist."
End If

End Sub



Sub OperateTableCheckBox(sBrowserName, sPageName, sTableName, sRow, sCol, sOperation,iTestNo)

' HELP
' method: OperateTableCheckBox()
' returns:
' parameter: sRow,sCol as Row &Col to Select/Deselect any Check Box of a Table
' parameter:
' notes: Selection Check box in the Specified table is option made ON/OFF .
' END

Dim SetCheckBox
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebTable(sTableName).Exist Then
Set SetCheckBox = Browser(sBrowserName).Page(sPageName).WebTable(sTableName).ChildItem(sRow, sCol, "WebCheckBox", 0)
SetCheckBox.Set sOperation
Call GenerateTestStatus(iTestNo, FCR_PASS, "Operate Check Box in Table ", "Check Box '" & sCheckBox & "' in table at Row" & CStr(sRow) & ", Column " & CStr(sCol) & " is made "&sOperation&".")
'Reporter.ReportEvent MicPass, "Web Table : " & CStr(sTableName), " Check Box in Row :" & CStr(sRow) & ":: of Column" & CStr(sCol) & " is set as " & CStr(sOperation)
Else
Call GenerateTestStatus(iTestNo, FCR_WARNING, "Operate Check Box in Table ", "Check Box '" & sCheckBox & "' in table at " & CStr(sRow) & ", Column " & CStr(sCol) & " is not found.")
'Reporter.ReportEvent MicFail, "Web Table :" & CStr(sTableName), " not Found in given Page :" & CStr(sPageName)
End If

End Sub


'CHK$$
Function GetNumObjectsinTable(sBrowserName, sPageName, sTableName, sObject,iTestNo)

' HELP
' method: GetNumObjectsinTable()
' returns:
' parameter: sObject as Type of the Object type to Check in Table
' notes: Returns number of Objects in a Table
' END
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebTable(sTableName).Exist Then

sCounter = 0

For sRow = 1 To Browser(sBrowserName).Page(sPageName).WebTable(sTableName).GetROProperty("rows")
ObjectExist = Browser(sBrowserName).Page(sPageName).WebTable(sTableName).ChildItemCount(sRow, sCol, sObject)
If ObjectExist = 1 Then
sCounter = sCounter + 1
End If
Next
Reporter.ReportEvent MicPass, "Type of the Object :" & CStr(sObject), "Number of Objects in Table are :" & CStr(sCounter)
Else
Reporter.ReportEvent MicFail, "Web Table :" & CStr(sTableName), " not Found in given Page :" & CStr(sPageName)
End If
GetNumObjectsinTable = sCounter
End Function


Sub VerifyStringLength(sBrowserName,sPageName,sString, sLen,iTestNo)

' HELP
' method: VerifyStringLength()
' returns: None
' parameter: sString as String ,sLen as Lenght of the String to Verify with
' notes: To verify for Expected String Length
' END

Browser(sBrowserName).Page(sPageName).sync
If Trim(Len(sString)) = Trim(sLen) Then
Reporter.ReportEvent MicPass, "Verification of length of a String : " & CStr(sString), "Sucessfully Verified Length of a String : " & CStr(sLen)
Else
Reporter.ReportEvent MicFail, "Verification of length of a String : " & CStr(sString), "Length of a String not Simliar " & CStr(sLen)
End If

End Sub


'CHK$$
Sub Compare_String(sStr1, sStr2,sPageName,iTestNo)

' HELP
' method: Compare_String(sStr1,sStr2)
' returns:
' parameter: sStr1:String 1 ;sStr2:String 2
' notes: Compares the given two strings.
' END


If StrComp(Trim(sStr1), Trim(sStr2)) = 0 Then
Reporter.ReportEvent micPass, "Compare String", "Given Strings are Similar "&vbNewLine&" String1: "&sStr1&vbNewLine&"String2: "&sStr2
Else
Reporter.ReportEvent micFail, "Compare String", "Given Strings are not Similar "&vbNewLine&" String1: "&sStr1&vbNewLine&"String2: "&sStr2
End If


End Sub



Sub AlertMessage_Close(sBrowserName, sDialogBox, sClick,iTestNo)

' ** NOTE: Make Sure You add OK /Cancel Button in your Object Repository File (*.tsr) **
' HELP
' method: AlertMessage_Close()
' returns: None.
' parameter: None
' notes: This method is to close pop up window
' END

If Browser(sBrowserName).Dialog(sDialogBox).Exist Then
Browser(sBrowserName).Dialog(sDialogBox).WinButton(sClick).Click
Call GenerateTestStatus(iTestNo, FCR_PASS, "Close Alert DialogBox", "DialogBox '" & sDialogBox & "' has closed successfully.")
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Close Alert DialogBox", "DialogBox '" & sDialogBox & "' does not exist.")
End If

End Sub



'CHK$$
Sub SelectMultipleWebListItems(sBrowserName, sPageName, sLstName, iItems, iIndex,iTestNo)

' HELP
' method: SelectMultipleWebListItems
' returns: none
' parameter: sLstName,sValue,iIndex
' notes: This will selects Items from the given list box based on the specified item count
' END
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebList("name:=" & sLstName, "html tag:=SELECT", "index:=" & iIndex).Exist Then
Browser(sBrowserName).Page(sPageName).WebList("name:=" & sLstName, "html tag:=SELECT", "index:=" & iIndex).Select 0
For iSelect = 0 To iItems
Browser(sBrowserName).Page(sPageName).WebList("name:=" & sLstName, "html tag:=SELECT", "index:=" & iIndex).ExtendSelect Int(iSelect)
Next
sSelectedValue = Browser(sBrowserName).Page(sPageName).WebList("name:=" & sLstName, "html tag:=SELECT", "index:=" & iIndex).GetROProperty("value")
Call GenerateTestStatus(iTestNo, FCR_PASS, "Select Multiple WebListItems", "WebList '" & sLstName & "' is exist and data selected is '" & CStr(sSelectedValue) & "' .")

Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Select Multiple WebListItems", "WebList '" & sLstName & "' doesn't exists .")

End If

End Sub


Sub ClickWebFile(sBrowserName, sPageName, sFileName,iTestNo)

' HELP
' method: ClickWebFile
' returns: It will clicks on the given Webfile in the page/application.
' parameter: sType,sFileName
' notes:
' END

Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebFile("html tag:=INPUT", "name:=" & sFileName, "type:=file").Exist Then

Browser(sBrowserName).Page(sPageName).sync

Browser(sBrowserName).Page(sPageName).WebFile("html tag:=INPUT", "name:=" & sFileName, "type:=file").Click
Call GenerateTestStatus(iTestNo, FCR_PASS, "Click WebFile", "WebFile '" & sFileName & "' is Clicked Successfully .")

Browser(sBrowserName).Page(sPageName).sync
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Click WebFile", "WebFile '" & sFileName & "' is unable to Click .")

End If

End Sub


Sub PopUpWindow_Close(sBrowserName)

'method: PopUpWindow_Close()
'returns: None
'parameter: sBrowserName
'Notes: PopUp Window appeared as browser page will be closed

Browser(sBrowserName).Close
Call GenerateTestStatus(iTestNo, FCR_DONE, "Close PopUp Window ", "PopUp Window appeared as browser page as '" & sBrowserName & "' is Closed Successfully .")

End Sub

'CHK$$
Function IsAlphabatic(sExpString,iTestNo)

' HELP
' method: IsAlphaNumeric(sString)
' returns: True/False of the execution
' parameter: sString: String to Check the Data Type
' notes: This is used to check whether String is an Alphabetic Type or not.
' END

Dim iString, sStringWord, regEx, Matches, sString, sString1, sString2, sString3

If sExpString = "" Then
Call GenerateTestStatus(iTestNo, FCR_DONE, "Is Alphabatic ", "No Value to Verify Data Type.")
Else

sString1 = Replace(sExpString, " ", GM_NULL) ' To Remove Spaces in the ExpString
sString2 = Replace(sString1, ".", GM_NULL) ' To Remove "." in the ExpString
sString3 = Replace(sString2, "-", GM_NULL) ' To Remove "-" in the ExpString
sString = Replace(sString3, "'", GM_NULL)
For iString = 1 To Len(sString)
sStringWord = Mid(sString, iString, 1)
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.Pattern = "[A-Z][a-z]"

Set Matches = regEx.Execute(sStringWord)
If Matches.Count = 0 Then
IsAlphabatic = False
Set Matches = Nothing
Set regEx = Nothing
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Is Alphabatic ", "Expected String '" & sExpString & "' not an Alphabatic Value.")

Exit Function
End If
IsAlphabatic = True
Set Matches = Nothing
Set regEx = Nothing
Next
Call GenerateTestStatus(iTestNo, FCR_PASS, "Is Alphabatic ", "Expected String '" & sExpString & "' is an Alphabatic Value.")

End If

End Function


Sub OperateTableRadioButton(sBrowserName, sPageName, sTableName, sRow, sCol, iNum,iTestNo)

' HELP
' method: OperateTableCheckBox()
' returns:
' parameter: sRow,sCol : Row &Col to Select/Deselect any Check Box of a Table
' parameter:
' notes: To Select the RadioButton in the Table
' END
Dim SetRadioButton
Browser(sBrowserName).Page(sPageName).sync
If Browser(sBrowserName).Page(sPageName).WebTable(sTableName).Exist Then
sRadioButtonexist = Trim(Browser(sBrowserName).Page(sPageName).WebTable(sTableName).ChildItemCount(sRow, sCol, "WebRadioGroup"))
If sRadioButtonexist = 1 Then
Set SetRadioButton = Browser(sBrowserName).Page(sPageName).WebTable(sTableName).ChildItem(sRow, sCol, "WebRadioGroup", 0)
SetRadioButton.Select iNum
sWebRadButton = GetCellData(sBrowserName, sPageName, sTableName, sRow, sCol,iTestNo)
Call GenerateTestStatus(iTestNo, FCR_PASS, "Operate Radio Button in Table ", "Radio Button '" & sWebRadButton & "' in table at " & CStr(sRow) & ", Column " & CStr(sCol) & " is selected Successfully .")


Else
Call GenerateTestStatus(iTestNo, FCR_WARNING, "Operate Radio Button in Table ", "Radio Button '" & sWebRadButton & "' in table at " & CStr(sRow) & ", Column " & CStr(sCol) & " is not found.")
End If
Else
Call GenerateTestStatus(iTestNo, FCR_FAIL, "Operate Radio Button in Table ", "Web Table '" & CStr(sTableName) & "' not found in a given Page :" & CStr(sPageName) & ".")
End If
End Sub

Comments

Popular posts from this blog

PDF Automation in QTP

                                                                            The most challenging issue with PDFs is that it could be of any kind, not just a tabular data; it could have plain text, images or even forms to fill up. So this makes a tester’s life a bit difficult, never mind, we will definitely find an easy of do it… Although there are already some better approaches we have to deal with PDF documents but I found many of us are facing so many difficulties using this. There are lots of queries coming at QTP forums asking for an easy way of doing it with PDFs. keeping those in my mind I started c...

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 :  ...

Download Test Resource From QC Using QTP

'########################################################################### '* Function Name: QCGetResource '* Designer: Jay '* Date 09-May-2012 '* This script will Download QC Test Resource to a local dir '########################################################################### Function QCGetResource(resourceName,saveTo)     Set qcConn = QCUtil.QCConnection     Set oResource = qcConn.QCResourceFactory     Set oFilter = oResource.Filter     oFilter.Filter("RSC_FILE_NAME") = resourceName     Set oResourceList = oFilter.NewList     If oResourceList.Count = 1 Then         Set oFile = oResourceList.Item(1)         oFile.FileName = resourceName         oFile.DownloadResource saveTo, True     End If         Set qcConn = Nothing     Set oResource = Nothi...

compare Two Text files using Vb Script

Public Function CompareFiles (FilePath1, FilePath2) Dim FS, File1, File2 Set FS = CreateObject(“Scripting.FileSystemObject”) If FS.GetFile(FilePath1).Size <> FS.GetFile(FilePath2).Size Then CompareFiles = True Exit Function End If Set File1 = FS.GetFile(FilePath1).OpenAsTextStream(1, 0) Set File2 = FS.GetFile(FilePath2).OpenAsTextStream(1, 0) CompareFiles = False Do While File1.AtEndOfStream = False Str1 = File1.Read(1000) Str2 = File2.Read(1000) CompareFiles = StrComp(Str1, Str2, 0) If CompareFiles <> 0 Then CompareFiles = True Exit Do End If Loop File1.Close() File2.Close() End Function Return value: The function returns 0 or False if the two files are identical, otherwise True. Example: File1 = “C:\countries\apple1.jpg” File2 = “C:\countries\apple3.jpg” If CompareFiles(File1, File2) = False Then MsgBox “Files are identical.” Else MsgBox “Files are different.” End If    Source: Mercury Forum’s KB articles

CreateImageFromClipBoard using QTP

'-------------------------------------------------------------------------' Method : CreateImageFromClipBoard' Author : Jai Purpose : It gets the clipboard image and convert as a image file.' Parameters: FileName - String, contains the BMP file name' iIndex - Integer, contains the Worksheet index' Returns : String. The replaced file name it gives.' Caller : - Nil' Calls : - Nil' ------------------------------------------------------------------------- Sub CreateImageFromClipBoard(sFileName) Dim wshShell,ShellReturnCode, sCmdExec Set WshShell = WScript.CreateObject("WScript.Shell") sCmdExec = "D:\autostuff\i_view32.exe /silent /clippaste /convert="& sFileName ShellReturnCode = WshShell.Run(sCmdExec, 1, True) End Sub