As we all know that we can automate the Web Applications by using only DOM + VBScript without having any automation tool. In this process we have to write the global functions to handle webobjects like links, edit boxes, radio buttons …etc.
I have got a requirement to automate an application only by using DOM + VBscript. For this process I have created all the global functions to handle every web object and stored all the functions in a library.
This is the plan I thought to Automate the Testcases Using DOM
Using Microsoft Script Control you can call one library functions in another library. For this you have to follow below steps.
Calling the Functions in other libraries
This is how we can use one Library functions / Variables in other libraries.
I have got a requirement to automate an application only by using DOM + VBscript. For this process I have created all the global functions to handle every web object and stored all the functions in a library.
This is the plan I thought to Automate the Testcases Using DOM
- Develop Global Functions to handle Web Objects
- Write scripts by calling global functions (scripts will be stored as VBS files)
Using Microsoft Script Control you can call one library functions in another library. For this you have to follow below steps.
- Read and store all the text from source library file using filesystem object
- Add the source library code as vbscript in MSScriptControl
- Call the functions using MSScriptControl methods
Dim a
a=20
Function demo ()
MsgBox "QTP Sudhakar"
End Function
Function demo_add (x,y)
demo_add = x+y
End Function
Calling the Functions in other libraries
This is how we can use one Library functions / Variables in other libraries.
'Create file system object
Set fso=CreateObject("scripting.filesystemobject")
'Open library file
Set sFile=fso.OpenTextFile("C:\Documents and Settings\sudhakar kakunuri\Desktop\Script Control\source.vbs")
'Read the complete data from library file
SourceLibraryData=sFile.ReadAll
'close the file
sFile.Close
'Create Script Control Object
Set scrControl=CreateObject("msscriptcontrol.scriptcontrol")
'Specify the language to be controlled
scrControl.Language = "VBScript"
'Add the source library code
scrControl.AddCode(SourceLibraryData)
'Diplay the number of procedures in th source library
MsgBox scrControl.Procedures.Count,,"Total Procedures Count"
'Display value of a variable in source library
Msgbox scrControl.Eval("a"),,"Value of Variable 'a'"
'Executing the function source library function
scrControl.Run "demo"
'Executing the function source library function with parameters
msgbox scrControl.Run("demo_add",10,20),,"demo_add function Result"
Thank you so much, You've helped me a lot!!
ReplyDelete