Forum Discussion

grace_ca's avatar
grace_ca
Occasional Contributor
4 years ago
Solved

How to perform on error close browser event?

Hi There

 

There is a annotation of @Before and @After(teardown) in Cucumber-JVM framework, which closes all the browsers on error. I am looking for the similar action in testComplete. The closest one is one on error control property. However, I am not sure if that is the right one to use for following reasons:

1. It seems tie to certain tests -- There are many different errors in tests. Object not find, time out, value not show....I need a way to close browser on any Log.error. 

2. Have trouble to understand how to use it. e.g. function EventControl1_OnLogError(Sender, LogParams){}

How to pass sender, and logParams passed?

3. It would be helpful if someone can give me a example for how to implement the global teardown action. 

 

Thanks!

Grace

  • grace_ca's avatar
    grace_ca
    4 years ago

    Yes. I did.

    When I added the onStopTest event control the popup ask you to select a test. It adds a function to that test script.

    I added content.

    function EventControl1_OnStopTest(Sender)
    {
    let browser = Aliases.browser;
    browser.Close();
    }

     

    At project level when I run the item I select the event/mehod.

    What is the sender parameter should it be? I don't any parameters. I am using script mode.

    Thanks!

  • Thanks Alex!

    I tried on my script with the event control it worked.  Just I don't know why it didn't work in project execution.

    Thanks for your help!

     

6 Replies