Skip to Content

Welcome to the 

Sahi Pro Customer Portal

Access your tickets, forums, courses and more, all in one single place

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
66 Views
We are facing an issue during sequential execution of multiple Windows desktop automation scripts in Sahi Pro.

Problem Description

When one of the test scripts fails, the application window (Teamcenet.exe) remains open. Because of this, the next test script is unable to launch the application cleanly. This leads to more failures and interrupts the entire execution flow.

Expected Behavior

When a test fails, the script should:

Close the application cleanly, or
Restore the environment to a known state

so that the next script can start with a fresh application instance.

Actual Behavior

  • The application window stays open after a failure
  • Subsequent scripts cannot launch the application
  • Execution of the entire batch is affected

Request for Guidance

Could you please advise on the recommended approach or configuration to ensure that:

  • The application is properly closed when a test fails, or
  • The environment is reset before the next script begins?
Avatar
Discard

Hi Daniel,

When a Sahi Pro desktop automation script fails (for example, due to an element not found), Sahi automatically triggers the default error callback function.
You can use this callback to ensure your application (e.g., Teamcenter.exe) is closed before the next script begins.

Please add the  app-closing logic in onScriptErrorDefault()

Follow these steps:

Go to: <Sahi Pro>/userdata/scripts/global_include.sah
Locate the function: onScriptErrorDefault()
Add your application-closing logic before the return statement.

Example:

_selectWindow();
if (_windowExists("/Teamcenter.exe/")) {
    _closeWindow();

}

Avatar
Discard