# Class webdriver.AlertPromise

code »

    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();
         });

## Constructor

webdriver.AlertPromise ( driver, alert )

Parameters
driver: `!webdriver.WebDriver` The driver controlling the browser this alert is attached to. alert: `!webdriver.promise.Thenable` A thenable that will be fulfilled with the promised alert.

Show:Public Protected Private

## Instance Methods

### Defined in `webdriver.AlertPromise`

code »cancel ( )
code »isPending ( ) ⇒ `boolean`
code »then ( ) ⇒ `webdriver.promise.Promise`
code »thenCatch ( ) ⇒ `webdriver.promise.Promise`
code »thenFinally ( ) ⇒ `webdriver.promise.Promise`

### Defined in `webdriver.Alert`

code »accept ( ) ⇒ `!webdriver.promise.Promise.<void>`

Accepts this alert.

Returns
A promise that will be resolved when this command has completed.

code »dismiss ( ) ⇒ `!webdriver.promise.Promise.<void>`

Dismisses this alert.

Returns
A promise that will be resolved when this command has completed.

code »getText ( ) ⇒ `!webdriver.promise.Promise.<string>`

Retrieves the message text displayed with this alert. For instance, if the alert were opened with alert("hello"), then this would return "hello".

Returns
A promise that will be resolved to the text displayed with this alert.

code »sendKeys ( text ) ⇒ `!webdriver.promise.Promise.<void>`

Sets the response text on this alert. This command will return an error if the underlying alert does not support response text (e.g. window.alert and window.confirm).

Parameters
text: `string` The text to set.
Returns
A promise that will be resolved when this command has completed.

## Instance Properties

### Defined in `webdriver.Alert`

code »driver_ : `!webdriver.WebDriver`
code »text_ : `!webdriver.promise.Promise.<string>`

## Static Properties

code »webdriver.AlertPromise.superClass_ : `webdriver.Alert.prototype`