Forum Discussion

georg_jezersek's avatar
georg_jezersek
Occasional Contributor
11 years ago

Event not fireing when scripting

Hi I tried a sample script from TestComplete and it runs a onload event request. I try to ad the response event and the script is just not recognizing this one.  Here is my sample script. The problem sub is ub GeneralEvents_OnLoadTestingResponse(Sender, User, Request)  Please help :-)



Sub Main

dim startTime,loadTime



set Station1 = LoadTesting.Stations.ItemByName("Master")

set Station2 = LoadTesting.Stations.ItemByName("Station1")



set TestInstance = LoadTesting.Tests.TestByName("Test").CreateTestInstance

For i = 0 To 1

Set HTTPTask = LoadTesting.HTTPTask("Task")

if (i = 0) Then

Set TestInstance.User(i).Station = Station1

else

Set TestInstance.User(i).Station = Station2

end if

Set TestInstance.User(i).Task = HTTPTask

next

call TestInstance.Run("Distributed")

End Sub



Sub GeneralEvents_OnLoadTestingRequest(Sender, User, Request)

Call Log.Message("Request_" & Request.RequestID & " Header", Request.RequestHeader)

startTime = aqDateTime.Time

' The body is empty for all GET requests

Call Log.Message("Request_" & Request.RequestID & " Body", Request.RequestBody.Contents)

loadTime = aqDateTime.Time - startTime

Call Log.Message("Subroutine Request load time:" & loadTime & "ms")

MsgBox "OnLoad Request"

End Sub



Sub GeneralEvents_OnLoadTestingResponse(Sender, User, Request)

startTime = aqDateTime.Time

' The body is empty for all GET requests

Call Log.Message("Request_" & Request.RequestID & " Body", Request.RequestBody.Contents)

loadTime = aqDateTime.Time - startTime

Call Log.Message("Subroutine Response load time:" & loadTime & "ms")

MsgBox "Response"

End Sub



6 Replies

  • georg_jezersek's avatar
    georg_jezersek
    Occasional Contributor
    Hi Alexei, thanks for the link and yes I did those steps. I even renamed the event to see if thismakes a difference. This was a sample project from SmartBaer I try to add events to.
  • georg_jezersek's avatar
    georg_jezersek
    Occasional Contributor
    Hi Alexei,

    what version of TestComplete did you use? I use version 8.70 and I can't get the HTTP events to be fired. I can get the other events like test start stopp and so on working but as soon I use onload or onrequest I get nothing.



    - GJ
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Georg,



    Last time I used Load Testing events with TC was also for version 8.7 (as this was the last version that contained load testing functionality). Everything worked fine for me, so this is rather strange that events are not fired in your case...

    What if you try to create a new project and check if the events are fired for it?
  • georg_jezersek's avatar
    georg_jezersek
    Occasional Contributor
    Hi Alexei,

    do you have a super simple script with a request and a response I could try?



    The stunning thing is. If I use their script and creat a new simple load task and rename their "Task" to "Task1" to execute my http recording the script will run but the event will not fire. If I rename it back to Task and execute the request event will fire.



    I am puzzeled. I created a complete fresh script and the HTTP events do not get triggert but if I use Engine events they work.



    I am out of ideas and SmartBaer support refuses to help.



    - GJ