Main Window and Menu Declarations

The main window declaration

The main window declaration begins with the 4Test reserved word window. The term window is historical, borrowed from operating systems and window manager software, where every GUI object, for example main windows, dialogs, menu items, and controls, is implemented as a window.

As is true for all window declarations, the declaration for the main window is composed of a class, identifier, and tag or locator.

Classic Agent Example

The following example shows the beginning of the default declaration for the main window of the Text Editor application:
window MainWin TextEditor
  multitag "Text Editor"
		"$C:\PROGRAMFILES\<SilkTest install directory>\SILKTEST\TEXTEDIT.EXE"
Part of Declaration Value for TextEditor's main window.
Class MainWin
Identifier TextEditor
Tag Two components in the multiple tag:
  • " Text Editor "—The application’s caption
  • " executable path "—The full path of the executable file that invoked the application

Open Agent Example

The following example shows the beginning of the default declaration for the main window of the Text Editor application:
window MainWin TextEditor
  locator "Text Editor"
Part of Declaration Value for TextEditor's main window.
Class MainWin
Identifier TextEditor
Locator " Text Editor "—The application’s caption

sCmdLine and wMainWindow constants

When you record the declaration for your application’s main window and menus, the sCmdLine and wMainWindow constants are created. These constants allow your application to be started automatically when you run your test cases.

The sCmdLine constant specifies the path to your application’s executable. The following example shows an sCmdLine constant for a Windows environment:
mswnt const sCmdLine = "c:\program files\<SilkTest install directory>\silktest\textedit.exe"
The wMainWindow constant specifies the 4Test identifier for the main window of your application. For example, here is the definition for the wMainWindow constant of the Text Editor application on all platforms:
const wMainWindow = TextEditor

Menu declarations

When you are working with the Classic Agent, the following example from the Text Editor application shows the default main window declaration and a portion of the declarations for the File menu:
window MainWin TextEditor
  multitag "Text Editor"
    "$C:\PROGRAM FILES\<SilkTest install directory>\SILKTEST\TEXTEDIT.EXE"
    .
    .
    .
    Menu File
      tag "File"
      MenuItem New
        multitag "New"
          "$100"
Menus do not have window IDs, but menu items do, so by default menus are declared with the tag statement while menu items are declared with the multitag statement.
When you are working with the Open Agent, the following example from the Text Editor application shows the default main window declaration and a portion of the declarations for the File menu:
window MainWin TextEditor
  locator "Text Editor"
    .
    .
    .
    Menu File
      locator "File"
      MenuItem New
        locator "@caption='New' or windowId='100'"