This is an old revision of the document!
Remote Agent - VBS
This is an example remote agent in VBS for QTP, TestComplete and other test automation tool that supports VBS (VB Scripting). This VBS runs within the target automation tools. It communicates with TestOptimal server to receive the test sequence generated from the model. You can easily turn the sequence command to function calls in QTP and TestComplete to test your application.
The script below can be found in “script” folder in the download package. The file is: TOAgent.vbs. For demonstration purpose this script can be run from Windows VBScript interpreter cscript.exe or WScript.exe. To run this demo, enter “cscript.exe TOAgent.vbs” in Windows DOS prompt or double click on TOAgent.vbs in Windows Explorer.
As TestOptimal executes the model, you should see the remote commands printed on the DOS console or popup debug window depending on which of the methods you choose to run TOAgent.vbs. When the model execution completes, the model execution summary is displayed.
'Copyright 2010, TestOptimal.com 'TOAgent.vbs
Dim agent Set agent = New TOAgent
'initialize agent with TestOptimal server host, port# and name of the model to execute agent.init "localhost", 8888, "Demo_RemoteAgent"
WScript.Echo "Starting the model execution..." agent.execModel "", ""
WScript.Echo "Sleeping for 3 seconds to wait for the model execution to start..." WScript.Sleep 3000
'obtain agent ID from server agentID = agent.getAgentID() WScript.Echo "agentID: " & agentID
'loop until no more remote commands received from server exitLoop = False Do Until exitLoop
'get the next remote command from the server curCmd = agent.getNextCmd()
'exit loop on error or receive empty remote command If (agent.getStatus = "E" Or curCmd = "") Then exitLoop = True Else ' add your logic to execute mbtCmd received from TestOptimal server ' "C" for completion, "X" for failure, "E" for fatal error (cause MBT to exit) WScript.Echo "Received remote cmd: " & curCmd agent.setStatus "C", "successfully executed " & curCmd End If Loop
WScript.Echo "Stopping the model..." agent.stopExec
WScript.Echo "Sleeping 2 seconds for the model to stop..." WScript.Sleep 2000
WScript.Echo "Saving the execution results to be viewed with TestOptimal browser..." agent.saveStat "exec from VBA agent"
WScript.Echo "Execution summary is: " & agent.getExecSummary agent.closeModel