CloseWindows Method

Class

MainWin.

Action

Closes all windows of the application except the main window.

Syntax

mainwin.CloseWindows ([bTrace])
Variable Description
bTrace Optional: TRUE to print a log in the results file of all windows closed; FALSE (default) not to print the log. BOOLEAN.

Notes

CloseWindows starts with the current active window and attempts to close it using the following sequence, stopping when the window closes:

  1. If a Close method is defined for the window, call it . Even if this method does not close the window, none of the following steps are executed.

  2. Call window.CloseBox.Click()(for Windows).

  3. Call window.SysMenu.Close.Pick() (on platforms and windows that have system menus).

  4. If the window is a dialog, type the keys specified in OPT_CLOSE_DIALOG_KEYS and wait one second for the dialog to close.

  5. If there is a single button in the window, click that button.

  6. Click the list of buttons specified with OPT_CLOSE_WINDOW_BUTTONS.

  7. Select the menus specified with OPT_CLOSE_WINDOW_MENUS.

Once one window closes, CloseWindows follow the sequence with the next window, until all windows are closed.

If closing any window causes the application to display a confirmation dialog, CloseWindows attempts to close the dialog using the list of buttons specified with the OPT_CLOSE_CONFIRM_BUTTONS option.

This method supports several specifications you can make to help Silk Test Classic close a window:

To specify Set this option Or set this variable
Non-standard buttons to use to close confirmation dialog OPT_CLOSE_CONFIRM_BUTTONS lsCloseConfirmButtons
If the UI of the application is in English, you only need to specify non-standard buttons that are used to close the window. If the UI of the application is not in English, you need to replace all strings, which correspond to buttons that are used to close a window, with the localized strings. OPT_CLOSE_WINDOW_BUTTONS lsCloseWindowButtons
If the UI of the application is in English, you only need to specify non-standard menu items that are used to close the window. If the UI of the application is not in English, you need to replace all strings, which correspond to menu items that are used to close a window, with the localized strings. OPT_CLOSE_WINDOW_MENUS lsCloseWindowMenus
Non-standard keys to type to close the window, if it is a dialog. OPT_CLOSE_DIALOG_KEYS lsCloseDialogKeys

You can make these specification by using the SetOption method, by defining the specified variable, or using the settings in the Close tab of the Agent Options dialog box.

Example

	[ ] RecoverBaseState ()
	[ ] TextEditor.CloseWindows () 
	[ ] ClearFile () 
	[-] do 
		[ ] VerifyBaseState ()
	[-] except
		[ ] LogError ("Error: Can’t return to base state")
	[ ] TextEditor.Exit () 
	[ ] TextEditor.Invoke ()