close

Close current window (and focus on an other window). If no window handle is given it automatically switches back to the first handle.

Usage

1
browser.close([windowHandle]);

Parameters

Param Type Details
windowHandle
optional
String new window to focus on

Example

close.js
1
2
3
4
5
6
7
8
9
10
11
12
it('should demonstrate the close command', function () {
browser.url('http://github.com')
browser.newWindow('http://google.com')

var title = browser.getTitle()
console.log(title) // outputs: "Google"

browser.close()

title = browser.getTitle()
console.log(title) // outputs: "GitHub · Build software better, together."
})

Uses