Friday, March 21, 2008

Class Mapping in VisualTest

Already Class Mapping is explained in Custom Objects . Visual test also provides class mapping. VisualTest coding is similar to Visual Basic. But both are not same and used for different purposes. Below code is to treat any given custom class as Button class.

Code snippet:



'--------------------------------------
' Method : WindowsCustomButtonClick
' Author : T.Palani Selvam
' Purpose : Clicks the given Button element.
' Parameters: sButton - String, Contains name of control
' sBtnValue - String, Contains value of control
' sCustomClass - String, contains custom class name.
' Returns : Integer
' Caller : WindowsHandleClick(sContext, sForm, sElement ,sElementValue , sElementType)
' Calls : - Nil -
'-------------------------------------------
Function WindowsCustomButtonClick(sButton As String, sBtnValue As String, sCustomClass As String) As Integer

WButtonSetClass(sCustomClass)
WindowsCustomButtonClick = WindowsButtonClick(sButton, sBtnValue)
wResetClasses()
End Function

'---------------------------------------
' Method : WindowsButtonClick
' Author : T.Palani Selvam
' Purpose : Clicks the given Button element.
' Parameters: sButton - String, Contains name of control
' sBtnValue - String, Contains value of control
' Returns : Integer.
' Caller : WindowsHandleClick(sContext, sForm, sElement ,sElementValue , sElementType)
' Calls : - Nil -
---------------------------------------
Function WindowsButtonClick(sButton As String, sBtnValue As String) As Integer

WindowsButtonClick = False

If (WButtonExists(sButton)) Then
WButtonClick(sButton)
LogWrite("Successfully clicked button " + sButton, 1)
WindowsButtonClick = True
Else
LogWrite("Failure to Click Button " + sButton,1)
End If

End Function

No comments: