Specifying Windows to be Left Open for Tests that Use the Open Agent

By default, the non-Web recovery system closes all windows in your test application except the main window. To specify which windows, if any, need to be left open — such as a child window that is always open — use the lwLeaveOpenWindows or lsLeaveOpenLocators constant.

lwLeaveOpenWindows and lsLeaveOpenLocators constants

When you record and paste the declarations for your application’s main window, the stub of a declaration for the lwLeaveOpenWindows constant is automatically included. Additionally, it is possible to specify windows to leave open by using XPath locator strings. These can be specified with the variable lsLeaveOpenLocators, which must be a list of strings. The following example shows the lwLeaveOpenWindows and lsLeaveOpenLocators constants before they have been edited:

// The list of windows the recovery system is to leave open
// const lwLeaveOpenWindows = {?}
// const lsLeaveOpenLocators = {?}

To complete the declaration for these constants:

  1. For lwLeaveOpenWindows, replace the question mark in the comment with the 4Test identifiers of the windows you want to be left open. Separate each identifier with a comma.
  2. For lsLeaveOpenLocators, click Record > Window Locators and record the locators that you want to include.
  3. Replace the question mark in the comment with the locator strings for the windows that you want to be left open. Separate each identifier with a comma.
  4. Remove the comment characters (the two forward slash characters) at the beginning of the lwLeaveOpenWindows declaration.

    For example, the following code shows how to set the lwLeaveOpenWindows constant so that the recovery system leaves open the window with the identifier DocumentWindow when it restores the BaseState.

    const lwLeaveOpenWindows = {DocumentWindow}
  5. Remove the comment characters (the two forward slash characters) at the beginning of the lsLeaveOpenLocators declaration.

    For example, the following code shows how to set the lsLeaveOpenLocators constant so that the recovery system leaves open the About dialog box when it restores the BaseState.

    lsLeaveOpenLocators = {“/MainWin[@caption=’*Information*’]”, “//Dialog[@caption=’About’]”}