Forum Discussion

socc3rpr0's avatar
socc3rpr0
Occasional Contributor
11 years ago

Event Handler(s)

Hello, 



I am trying to figure out if there is ONE event handler that covers all the bases such as window not recognize, unable to find object, or manually posting an error to the log (for me it stops execution), or an actual engine error occur, etc..



The problem I have is that in my main function the first thing I do is open a TCP connection to the device under test and then run through all my test scripts, but when they fail I want to be able to close the connection and then post the error. So next time I can start the main function again and reopen the TCP connection and so forth. For example



function main()

{

 

      EstablishConnection();





}







1 Reply

  • Hi Ed,



    Looks like you are using JScript. you can try out below if helps.



    1. you can use a try.. catch .. finally block and put the code for closing the connection in finally block in your main function.

    2. you can put your own function or code into OnStopTest to close the connection

    3. you can also put your own code into OnLogError event to verify the exact error text and if the error message is of a TCP connection failure, then close the connection.



    Hope this helps.