Thursday, July 31, 2008

VisualTest - Browser related functions

VisualTest has different set of functions for browser related operations. Below I have given few code snippets.

VistualTest code - To Invoke Internet Explorer

'--------------------------- ' Method : WebStart ' Author : T.Palani Selvam ' Purpose : To Start a IE. ' Parameters: sURL As String. ' ' Returns : - Nil - ' Caller : - Nil ' Calls : - Nil - '----------------------------- Sub WebStart(sURL As String) gsContext = WebExplore(sURL) WSetActWnd(val(gsContext)) If Not wIsMaximized(val(gsContext)) Then wMaxWnd(val(gsContext)) Sleep giPageLoad Logwrite("IE is started. URL : " + sURL , 1) End Sub

Vistual Test code - Navigate to given URL
'------------------------ ' Method : WebNavigation ' Author : T.Palani Selvam ' Purpose : To Start a IE. ' Parameters: sURL As String. ' ' Returns : - Nil - ' Caller : - Nil ' Calls : - Nil - '--------------------------- Sub WebNavigation(sURL As String) If ( Not WebBrowserExists(gsContext)) Then WebStart(sURL) Else WebNavigate(gsContext, sURL) Sleep giPageLoad WSetActWnd(val(gsContext)) If Not wIsMaximized(val(gsContext)) Then wMaxWnd(val(gsContext)) Logwrite("Navigated URL : " + sURL , 1) End If End Sub

Vistual Test code - To click Back Button in Browser
'-------------------------- ' Method : WebBackHistory ' Author : T.Palani Selvam ' Purpose : Back history from IE. ' Parameters: sValue As String. ' ' Returns : - Nil - ' Caller : - Nil ' Calls : - Nil - '----------------------------- Sub WebBackHistory(sValue As String) Dim iTimes As Integer iTimes = Val(sValue) If ( Not WebBrowserExists(gsContext)) Then LogWrite("Main Browser doesn't exist.Couldn't be gone to back", 1) Else If (iTimes = 0) Then iTimes = 1 WebBack(gsContext, iTimes) Sleep giPageLoad WSetActWnd(val(gsContext)) If Not wIsMaximized(val(gsContext)) Then wMaxWnd(val(gsContext)) Logwrite("Going back number of items in History is " + str(iTimes) , 1) End If End Sub

Vistual Test code - To click Forward Button in Browser
'--------------------------- ' Method : WebForwardHistory ' Author : T.Palani Selvam ' Purpose : Forward history from IE. ' Parameters: sValue As String. ' ' Returns : - Nil - ' Caller : - Nil ' Calls : - Nil - '--------------------------------- Sub WebForwardHistory(sValue As String) Dim iTimes As Integer iTimes = Val(sValue) If ( Not WebBrowserExists(gsContext)) Then LogWrite("Main Browser doesn't exist.Couldn't be gone to Forward", 1) Else If (iTimes = 0) Then iTimes = 1 WebForward(gsContext, iTimes) Sleep giPageLoad WSetActWnd(val(gsContext)) If Not wIsMaximized(val(gsContext)) Then wMaxWnd(val(gsContext)) Logwrite("Going Forward number of items in History is " + str(iTimes) , 1) End If End Sub

1 comment:

Tee Chess said...

Thanks for the information. I will try those code snippets. But could you please give some more details that will help more.. Software Testing Services