Forum Discussion

Prav_Akula's avatar
New Contributor
11 months ago

when test case fails in test complete, how to close the desktop application.

In our desktop application, it has multiple windows.


When we do a regression group run, if a test case fails, multiple windows remain open and this affects other test case execution, causing more failures. So, when test case fails immediately it should close all windows opened in testcase. So, that it will not affect other test cases.


How to achieve this using Python in a Test Complete. 

3 Replies

  • EdenWheeler's avatar
    Occasional Contributor


    To close all the windows opened during a failed TestComplete test case using Python, you can use the following code snippet:


    def close_application():
        # Close all windows
        desktop = TestedApps.ApplicationName
    # Call the function to close windows



    The CloseAllWindows() method is used to close all open windows in the application. You can customize this method based on your application's name and other requirements.

    You can call this function at the end of your test case, or when a test case fails. This will ensure that all windows are closed before the next test case starts executing.


    I hope this will help you.

    • Prav_Akula's avatar
      New Contributor

      Thank you for quick response. I will try and let you know the result.