Namespace: webdriver
View Source

# class WebDriver.Options

Provides methods for managing browser and driver state.

## new WebDriver.Options(driver)

Parameters

driver`webdriver.WebDriver`

  The parent driver.

## Instance Methods

### addCookie(name, value, opt_path, opt_domain, opt_isSecure, opt_expiry)code »

Schedules a command to add a cookie.

Parameters

name`string`

  The cookie name.

value`string`

  The cookie value.

opt_path`string=`

  The cookie path.

opt_domain`string=`

  The cookie domain.

opt_isSecure`boolean=`

  Whether the cookie is secure.

opt_expiry`(number|Date)=`

  When the cookie expires. If specified as a number, should be in milliseconds since midnight, January 1, 1970 UTC.

Returns

`webdriver.promise.Promise<undefined>`

  A promise that will be resolved when the cookie has been added to the page.

### deleteAllCookies()code »

Schedules a command to delete all cookies visible to the current page.

Returns

`webdriver.promise.Promise<undefined>`

  A promise that will be resolved when all cookies have been deleted.

### deleteCookie(name)code »

Schedules a command to delete the cookie with the given name. This command is a no-op if there is no cookie with the given name visible to the current page.

Parameters

name`string`

  The name of the cookie to delete.

Returns

`webdriver.promise.Promise<undefined>`

  A promise that will be resolved when the cookie has been deleted.

### getCookie(name)code »

Schedules a command to retrieve the cookie with the given name. Returns null if there is no such cookie. The cookie will be returned as a JSON object as described by the WebDriver wire protocol.

Parameters

name`string`

  The name of the cookie to retrieve.

Returns

`webdriver.promise.Promise<?{domain: (string|undefined), expiry: (number|undefined), name: string, path: (string|undefined), secure: (boolean|undefined), value: string}>`

  A promise that will be resolved with the named cookie, or `null` if there is no such cookie.

### getCookies()code »

Schedules a command to retrieve all cookies visible to the current page. Each cookie will be returned as a JSON object as described by the WebDriver wire protocol.

Returns

`webdriver.promise.Promise<Array<{domain: (string|undefined), expiry: (number|undefined), name: string, path: (string|undefined), secure: (boolean|undefined), value: string}>>`

  A promise that will be resolved with the cookies visible to the current page.

### logs()code »

Returns

`webdriver.WebDriver.Logs`

  The interface for managing driver logs.

### timeouts()code »

Returns

`webdriver.WebDriver.Timeouts`

  The interface for managing driver timeouts.

### window()code »

Returns

`webdriver.WebDriver.Window`

  The interface for managing the current window.

## Type Definitions

Options.Cookie`{domain: (string|undefined), expiry: (number|undefined), name: string, path: (string|undefined), secure: (boolean|undefined), value: string}`

  A JSON description of a browser cookie.