Skip to main content

[Windows] Switch to Window Title

Description

Find and attach the opening application window that describes by the given windows object to the working WindowsDriver session on the current desktop by the given title.

This keyword should be used when the main application window has been closed and replaced by another window, the application has multiple working windows (We can switch among these windows), or we already have an opened application and need to switch to without reopening.

Keyword name: switchToWindowTitle

Parameters

Parameter Parameter TypeRequiredDescription
windowTitleStringYesTitle of the opening application windows. Full text, partial text, or regular expression input is acceptable.
matchingStrategyStringMatchingStrategy (enum)OptionalSpecifies the strategy to match the windowTitle parameter against the actual window title. Allowed values are:
  • CONTAINS: (default value) The windowTitle parameter should be a substring of the actual window title.

  • REGEXP: The windowTitle parameter should be a valid regular expression pattern that matches the actual window title.

  • EXACT: The windowTitle parameter should exactly match the actual window title.

flowControlFailureHandlingOptionalSpecify failure handling schema to determine whether the execution should be allowed to continue or stop.

Returns

Parameter TypeDescription
WindowsDriverThe WindowsDriver after Katalon Studio switches successfully.
StepFailedExceptionThrows an error if Katalon Studio could not find any window that matches with the given windows object.

Example

Windows.switchToWindowTitle("Excel")

Setting timeout

In previous Katalon Studio versions, users may have encountered the timeout exception during recording a Desktop application and executing a Windows test.

To address this issue, from version 7.5.5 and later versions, Katalon Studio increased the default timeout for finding a Windows title from 60 to 120 seconds when recording and executing tests.

Additionally, users are now allowed to change this default timeout value when using the keyword for executing tests via Script (in milliseconds) to make sure the WinAppDriver has enough time to perform the action.

For example:
import com.kms.katalon.core.windows.keyword.helper.WindowsActionSettings

'Change the default timeout for finding a Windows title to 180000 milliseconds'
WindowsActionSettings.DF_WAIT_ACTION_TIMEOUT_IN_MILLIS = 180000;
Was this page helpful?