Stylesheet user/screen.css not found, please contact the developer of "vector" template.
Stylesheet user/print.css not found, please contact the developer of "vector" template.
Stylesheet user/rtl.css not found, please contact the developer of "vector" template.


This shows you the differences between two versions of the page.

Link to this comparison view

remoteagentvba [2016/09/22 02:36] (current)
Line 1: Line 1:
 +===== Remote Agent - VBA =====
 +This is an example remote agent in VBA to communicate with //TestOptimal// server. The agent will be driven by //TestOptimal// server to execute the test sequence remotely on your application under test (AUT).
 +Below is an example of a VBA agent. This demo is included in the download package. Find the excel file named "TOAgent.xls" in folder "script". To run this demo, just open the "TOAgent.xls" and press "Alt-F8" to run the macro "RunTOAgent".
 +You should see remote commands received from the server in a popup dialog window. When the execution completes, it will display the model execution summary in a popup dialog window.
 +If you want to run this demo within your own Excel document, MS Access or others, create the following scripts and include TOAgent.vba to the project:
 +    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
 +    Sub RunTOAgent()
 +      Dim agent As TOAgent
 +      Dim agentID As String
 +      Dim curCmd As String
 +      Dim showNextCmd As String
 +      'create agent object
 +      Set agent = New TOAgent
 +      'TestOptimal server host localhost, port# 8888, modelName Demo_RemoteAgent
 +      agent.init "localhost", 8888, "Demo_RemoteAgent"
 +      'start model execution on TestOptimal server. Params are user id and password.
 +      agent.execModel "", ""
 +      'wait 2 seconds to make sure the model execution is started.
 +      Sleep 2000
 +      'obtains the agent id from TestOptimal server
 +      agentID = agent.getAgentID()
 +      showNextCmd = vbYes
 +      exitLoop = False
 +      'loops until no more remote commands received from the server.
 +      Do Until exitLoop
 +         'obtains the next remote command from the server
 +         curCmd = agent.getNextCmd()
 +         'exit loop on any error or 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)
 +           If showNextCmd = vbYes Then
 +             showNextCmd = MsgBox("Received remote cmd: " & curCmd & ". Do you wish to display next command? Answer No to run to the end without pause.", vbQuestion + vbYesNo, "Command from " & model)
 +           End If
 +           agent.setStatus "C", "successfully executed " & curCmd
 +         End If
 +      Loop
 +      'stop the model execution
 +      agent.stopExec
 +      'wait for 2 second for the model exeution to stop
 +      Sleep 2000
 +      'save the model execution results to be reviewed later with TestOptimal Browser.
 +      agent.saveStat "exec from VBA agent"
 +      MsgBox "Execution summary is: " & agent.getExecSummary
 +      agent.closeModel
 +    End Sub
 +It ueses "Microsoft WinHttp Services" package which can be enabled with "Tools" / "References" in Microsoft Excel.
 +Since Release 3.0
QR Code
QR Code remoteagentvba (generated for current page)