Forum Discussion

jdemmers's avatar
jdemmers
New Contributor
3 years ago
Solved

Orders example project. How to handle confirmation dialog for failed test.

Currently doing some test with the Orders example project.

"C:\Users\Public\Documents\TestComplete 15 Samples\Desktop\Orders\C#\bin\Release\Orders.exe"

 

Tutorial works fine. Tutorial is for a Desktop test using keyword tests.

https://support.smartbear.com/testcomplete/docs/tutorials/getting-started/first-test/desktop/index.html

 

My problem:

Want to create two tests. First one (Test1) should fail, second one (Test2) should succeed.
When Test1 fails it should stop with the current test and continue with Test2.


Project config

Test config

It looks like the config is working. When the first test fails it tries to close the Orders program.

 

However it can't handle the save confirmation dialog when closing the program. At this point the tests are stuck and Test2 fails as well because Test1 was never able to close the Orders program.

 

Is it possible to handle this behavior correctly using keyword tests? or does this require scripting? 

 

 

 

 

 

  • Got it working by adding an event handler for the OnStop event.

    function GeneralEvents_OnStopTest(Sender)
    {
      if (Sys.WaitProcess("Orders", 2000).Exists)
      {
        Sys.Process("Orders").Terminate()
      }
    }

     

    If there is a better solution feel free to post it.

1 Reply

  • jdemmers's avatar
    jdemmers
    New Contributor

    Got it working by adding an event handler for the OnStop event.

    function GeneralEvents_OnStopTest(Sender)
    {
      if (Sys.WaitProcess("Orders", 2000).Exists)
      {
        Sys.Process("Orders").Terminate()
      }
    }

     

    If there is a better solution feel free to post it.