Change focus to another window. The window to change focus to may be specified by its server assigned window handle, or by the value of its name attribute.

To find out the window handle use windowHandles command

Usage

Example

Or run locally with:
git clone https://github.com/nightwatchjs/nightwatch-examples.git
cd nightwatch-examples
npm install
npx nightwatch tests/api/switchToWindow.js

Parameters

Name Type description
handleOrName string

The server assigned window handle or the name attribute.

callback
Optional
function

Optional callback function to be called when the command finishes.

See also