Close the current window or tab. This can be useful when you're working with multiple windows/tabs open (e.g. an OAuth login).

After closing a window or tab, you must switch back to a valid window handle (using .window.switchTo() command) in order to continue execution.

Usage

                    .window.close([callback])
                

Example

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

Parameters

Name Type description
callback
Optional
function

Optional callback function to be called when the command finishes.

See also

W3C WebDriver spec