Open and close applications
Relevant for: GUI actions and function libraries
In addition to using the Record and Run Settings Dialog Box (for tests) to instruct UFT One to open a new application when a run session begins, or manually opening the application you want to test, you can insert statements into your test or component that open and close the applications you want to test.
You can run any application from a specified location using a SystemUtil.Run statement. You can specify an application and pass any supported parameters, or you can specify a file name and the associated application starts with the specified file open.
This is especially useful in the following situations:
If your test includes more than one application, and you selected the Record and run test on any application check box in the Record and Run Settings Dialog Box.
If you want to provide an operation (function) that opens an application from within a component.
You can close most applications using the Close method. You can also use SystemUtil statements to close applications.
For example, you could use the following statements to open a file named type.txt in the default text application (Notepad), type happy days, save the file using shortcut keys, and then close the application:
SystemUtil.Run "C:\type.txt", "","","" Window("Text:=type.txt - Notepad").Type "happy days" Window("Text:=type.txt - Notepad").Type micAltDwn & "F" & micAltUp Window("Text:=type.txt - Notepad").Type micLShiftDwn & "S" & micLShiftUp Window("Text:=type.txt - Notepad").Close