Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

SilkTest Workbench: How can an application be launched from a Workbench .Net script, without using the BaseState; and kept running between tests executed from Silk Central?

SilkTest Workbench: How can an application be launched from a Workbench .Net script, without using the BaseState; and kept running between tests executed from Silk Central?

In some scenarios it may be beneficial or even neceesary; to launch an application under test through a .Net script, rather than using the built-in BaseState functionality. A typical way to accomplish this is to use the Process.Start() method of the System.Diagnostics namespace. e.g.

However when this script is run from SilkCentral it is executed from the commandline program(STW.exe) and a Windows Job object is created. This approach is adopted so that, in the event that the Workbench or STW.exe processes crash, the launched application will also be closed automatically.

One side effect of this approach is that any child processes launched by the Workbench(including any processes started through the script); are closed automatically when the test is completed. This is not an issue when running tests directly from the Workbench; but when the same script runs from SilkCentral, the notepad application will close when the Workbench terminates on completion of the script. This behavior may not be the desired if you need the application to remain running between tests.

The solution is to specify the 'CREATE_BREAKAWAY_FROM JOB' flag when launching the application; but unfortunately the Process class used in the example does not expose the functionality to do this, so the Win32 function must be called directly. The steps to accomplish this are as follows:

1. Create the Win32 class as follows and add a reference to it in your script:

 2. Create the RunProcess class that will contain the Start() method, and add a reference to the class in your script:

3. Modify the script to call the Start() method in the RunProcess class to launch the specified application:

You can find the exported script attached to this article - please note that this solution required some changes to STW.exe, so this approach is only valid for SilkTest 17.5 and newer.

[View:/cfs-file/__key/communityserver-wikis-components-files/00-00-00-01-00/FullScript.zip:100:24]

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2017-04-20 15:59
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.