[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 Type | Required | Description |
---|---|---|---|
windowTitle | String | Yes | Title of the opening application windows. Full text, partial text, or regular expression input is acceptable. |
matchingStrategy | StringMatchingStrategy (enum) | Optional | Specifies the strategy to match the windowTitle parameter against the actual window title. Allowed values are:
|
flowControl | FailureHandling | Optional | Specify failure handling schema to determine whether the execution should be allowed to continue or stop. |
Returns
Parameter Type | Description |
---|---|
WindowsDriver | The WindowsDriver after Katalon Studio switches successfully. |
StepFailedException | Throws 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.
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;