Namespace: webdriver
View Source

# class AlertPromise

final

    webdriver.Alert
      └ webdriver.AlertPromise

All implemented interfaces:
  `webdriver.promise.Thenable<webdriver.Alert>`

AlertPromise is a promise that will be fulfilled with an Alert. This promise serves as a forward proxy on an Alert, allowing calls to be scheduled directly on this instance before the underlying Alert has been fulfilled. In other words, the following two statements are equivalent:

    driver.switchTo().alert().dismiss();
    driver.switchTo().alert().then(function(alert) {
      return alert.dismiss();
    });

## new AlertPromise(driver, alert)

Parameters

driver`webdriver.WebDriver`

  The driver controlling the browser this alert is attached to.

alert`webdriver.promise.Thenable<webdriver.Alert>`

  A thenable that will be fulfilled with the promised alert.

## Instance Methods

### accept()code »

Defers action until the alert has been located.

Overrides: webdriver.Alert

### cancel(arg0)code »

Specified by: webdriver.promise.Thenable

Parameters

arg0`?(string|webdriver.promise.CancellationError)=`

### dismiss()code »

Defers action until the alert has been located.

Overrides: webdriver.Alert

### getText()code »

Defer returning text until the promised alert has been resolved.

Overrides: webdriver.Alert

### isPending()code »

Specified by: webdriver.promise.Thenable

Returns

`boolean`

### sendKeys(text)code »

Defers action until the alert has been located.

Overrides: webdriver.Alert

Parameters

text`?`

### then(arg0, arg1)code »

Specified by: webdriver.promise.Thenable

Parameters

arg0`?function(webdriver.Alert): (R|IThenable<R>)=`
arg1`?function(*): (R|IThenable<R>)=`

Returns

`webdriver.promise.Promise`

### thenCatch(arg0)code »

Specified by: webdriver.promise.Thenable

Parameters

arg0`function(*): (R|IThenable<R>)`

Returns

`webdriver.promise.Promise`

### thenFinally(arg0)code »

Specified by: webdriver.promise.Thenable

Parameters

arg0`function(): (R|IThenable<R>)`

Returns

`webdriver.promise.Promise`