Showing posts with label webtesting. Show all posts
Showing posts with label webtesting. Show all posts

Thursday, June 12, 2008

VisualTest - Functions by web Tag

Visual Test has the flexibility to click the web objects by the tag. Even you can verify whether the tag exists or not in the web page. Below I've given code snippets to use tag related functions.

VisualTest code : Click based on the given tag details.

'------------------- ' Method : WebClickTag ' Author : T.Palani Selvam ' Purpose : Click based on the given tag. It is useful to nonform tags. ' Parameters: sContext - String, contains web context value. ' sForm - String, contains part of title. ' sTag - String, contains tag data. ' sTagType - String, type of tag to be processed. ' Returns : Returns Integer, either TRUE or FALSE ' Caller : ' Calls : - Nil - '----------------------- Function WebClickTag (sContext As String, sForm As String, sTagType As String, sTag As String) AS Integer WebClickTag = FALSE If WebTagExists(sContext, sTag, sTagType) Then WebTagClick(sContext, sTag, sTagType) LogWrite("Successfully Clicked tag: " + sTagType, 1) WebClickTag = TRUE Else LogWrite("Failure to Click tag: " + sTagType, 1) End IF End Sub


Visual Test code: Check object exists based on the given tag
'--------------------- ' Method : WebTagCheck ' Author : T.Palani Selvam ' Purpose : Check objectexists based on the given tag. It is useful to nonform tags. ' Parameters: sContext - String, contains web context value. ' sForm - String, contains part of title. ' sTag - String, contains tag data. ' sTagType - String, type of tag to be processed. ' Returns : Returns Integer, either TRUE or FALSE ' Caller : ' Calls : - Nil - '--------------------- Function WebTagCheck (sContext As String, sForm As String, sTagType As String, sTag As String) AS Integer WebTagCheck = FALSE If WebTagExists(sContext, sTag, sTagType) Then LogWrite("Successfully Checked tag: " + sTagType, 1) WebTagCheck = TRUE Else LogWrite("Failure to Click tag: " + sTagType, 1) End IF End Sub

Wednesday, June 11, 2008

VisualTest - Radio button functions

Last week, I interviewed one guy and he is using VisualTest in his company. I'm surprised. IBM - Rational VisualTest development was stopped about seven years ago and Still people are using the tool. Here I have given code snippet for Handling Radio buttons in the browser.

Sample VisualTest Code:



'--------------------------------
' Method : WebClickRadio
' Author : T.Palani Selvam
' Purpose : Selects the Radio Button to the given value.
' Parameters: sContext - String, Contains web context
' sForm - String, contains information about Form
' sRadioButton - String, Contains name of control
' sRadioValue - String, Contains value of control
' Returns : Returns Integer, either TRUE or FALSE
' Caller : WebHandleClick(sContext, sForm, sElement ,sElementValue , sElementType)
' Calls : - Nil -
'-----------------------------
Function WebClickRadio(sContext As String, sForm As String, sRadioButton As String,sRadioValue As String) As Integer
Dim iIndex as Integer, iCount As Integer
Dim sControl As String, sTemp As String
Dim lItem As Long, lState As Long

WebClickRadio = FALSE
If (WebRadioExists(sContext,sForm,sRadioButton)) Then
If (Instr(LCase(sRadioValue),"check") = 1 OR Instr(LCase(sRadioValue),"select") = 1) Then
lState = SELECTED
Else
lState = NOTSELECTED
End IF

If (Instr(sRadioButton,"@") = 0) Then
iCount = WebInputelementCount(sContext, sForm,"radio")
For iIndex= 1 To iCount
lItem = iIndex
sControl = Str$(WebInputElementProperty(sContext,sForm, _ord(lItem), "radio", "name"))
sTemp = Str$(WebInputElementProperty(sContext,sForm, _ord(lItem), "radio", "value"))

Print sControl,sTemp

If ((Instr(Lcase(sRadioButton),lcase(sControl)) <> 0) AND (Lcase(Trim(sRadioValue)) = lcase(sTemp))) Then
WebRadioSetState(sContext, sForm, _ord(lItem), lState)
'WebInputElementSetState(sContext,sForm, _ord(lItem), "radio", SELECTED)
WebClickRadio = TRUE
LogWrite("Successfully set the state for radio button " + sRadioButton, 1)
Exit Function
End IF
Next iIndex
LogWrite("Failure to set the state for radio button " + sRadioButton, 1)
Else
WebRadioSetState(sContext, sForm,sRadioButton, lState)
WebClickRadio = TRUE
LogWrite("Successfully set the state for radio button " + sRadioButton, 1)
End IF
Else
LogWrite("Doesn't exist radio button " + sRadioButton, 1)
End IF
End Function


Sample Visual Test Code: Checks the selected Radio Button to the given value


'---------------------------
' Method : WebRadioCheck
' Author : T.Palani Selvam
' Purpose : Checks the selected Radio Button to the given value.
' Parameters: sContext - String, Contains web context
' sForm - String, contains information about Form
' sRadioButton - String, Contains name of control
' sRadioValue - String, Contains value of control
' Returns : Returns Integer, either TRUE or FALSE
' Caller : WebHandleCheck(sContext, sForm, sElement ,sElementValue , sElementType)
' Calls : - Nil -
'--------------------------
Function WebRadioCheck(sContext As String, sForm As String, sRadioButton As String,sRadioValue As String) As Integer
Dim iValue As Integer, iState AS Integer

WebRadioCheck = FALSE
If (WebRadioExists(sContext,sForm,sRadioButton)) Then
If (Instr(LCase(sRadioValue),"check") = 1 OR Instr(LCase(sRadioValue),"select") = 1) Then
iState = SELECTED
Else
iState = NOTSELECTED
End IF

iValue = WebRadioState(sContext, sForm, sRadioButton)
If (iState = iValue) Then
LogWrite("Successful to check Radio " + sRadioButton,1)
WebRadioCheck = TRUE
Else
LogWrite("Failure to check Radio " + sRadioButton ,1)
End IF
Else
LogWrite("Doesn't exist radio button " + sRadioButton, 1)
End IF

End Function

Wednesday, April 23, 2008

Tooltip verification in Browser

SilkTest does not have any built-in function, to get tooltip from browser controls. In browser, there is no ToolTip control, but the few attributes (Alt) are used to simulate a ToolTip.

Using Silktest, we can execute javascript statements in browser at runtime. By using that, we can get tooltip from web objects. In the following example sAltProp variable gets the tooltip of AutoImage object.

STRING sAltProp = MyApp.AutoImage.ExecMethod('getAttribute("alt")')

Similarly we can use javascript to get more info from any browser based objects. QTP is using VBScript. Using QTP also, we can achieve the same like above.