Class webdriver.Alert

code »
webdriver.promise.Promisewebdriver.promise.Deferred
      └ webdriver.Alert

Represents a modal dialog such as alert, confirm, or prompt. Provides functions to retrieve the message displayed with the alert, accept or dismiss the alert, and set the response text (in the case of prompt).

Constructor

webdriver.Alert ( driver, text )
Parameters
driver: !webdriver.WebDriver
The driver controlling the browser this alert is attached to.
text: !(string|webdriver.promise.Promise)
Either the message text displayed with this alert, or a promise that will be resolved to said text.
Show:

Instance Methods

Defined in webdriver.Alert

Accepts this alert.

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

Dismisses this alert.

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

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.

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.

Defined in webdriver.promise.Deferred

code »errback ( opt_error )

Rejects this promise. If the error is itself a promise, this instance will be chained to it and be rejected with the error's resolved value.

Parameters
opt_error: *=
The rejection reason, typically either a Error or a string.
code »fulfill ( opt_value )

Resolves this promise with the given value. If the value is itself a promise and not a reference to this deferred, this instance will wait for it before resolving.

Parameters
opt_value: *=
The resolved value.
code »reject ( opt_error )

Rejects this promise. If the error is itself a promise, this instance will be chained to it and be rejected with the error's resolved value.

Parameters
opt_error: *=
The rejection reason, typically either a Error or a string.

Removes all of the listeners previously registered on this deferred.

Throws
Error
If this deferred has already been resolved.

Defined in webdriver.promise.Promise

code »addBoth ( callback, opt_self )!webdriver.promise.Promise
Deprecated: Use #thenFinally() instead.

Registers a function to be invoked when this promise is either rejected or resolved. This function is provided for backwards compatibility with the Dojo Deferred API.

Parameters
callback: Function
The function to call when this promise is either resolved or rejected. The function should expect a single argument: the resolved value or rejection error.
opt_self: !Object=
The object which |this| should refer to when the function is invoked.
Returns
A new promise which will be resolved with the result of the invoked callback.
code »addCallback ( callback, opt_self )!webdriver.promise.Promise
Deprecated: Use #then() instead.

Registers a function to be invoked when this promise is successfully resolved. This function is provided for backwards compatibility with the Dojo Deferred API.

Parameters
callback: Function
The function to call if this promise is successfully resolved. The function should expect a single argument: the promise's resolved value.
opt_self: !Object=
The object which |this| should refer to when the function is invoked.
Returns
A new promise which will be resolved with the result of the invoked callback.
code »addCallbacks ( callback, errback, opt_self )!webdriver.promise.Promise
Deprecated: Use #then() instead.

An alias for webdriver.promise.Promise.prototype.then that permits the scope of the invoked function to be specified. This function is provided for backwards compatibility with the Dojo Deferred API.

Parameters
callback: Function
The function to call if this promise is successfully resolved. The function should expect a single argument: the promise's resolved value.
errback: Function
The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.
opt_self: !Object=
The object which |this| should refer to when the function is invoked.
Returns
A new promise which will be resolved with the result of the invoked callback.
code »addErrback ( errback, opt_self )!webdriver.promise.Promise
Deprecated: Use #thenCatch() instead.

Registers a function to be invoked when this promise is rejected. This function is provided for backwards compatibility with the Dojo Deferred API.

Parameters
errback: Function
The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.
opt_self: !Object=
The object which |this| should refer to when the function is invoked.
Returns
A new promise which will be resolved with the result of the invoked callback.
code »cancel ( reason )

Cancels the computation of this promise's value, rejecting the promise in the process.

Parameters
reason: *
The reason this promise is being cancelled. If not an Error, one will be created using the value's string representation.
Returns
Whether this promise's value is still being computed.
code »then ( opt_callback, opt_errback )!webdriver.promise.Promise

Registers listeners for when this instance is resolved. This function most overridden by subtypes.

Parameters
opt_callback: Function=
The function to call if this promise is successfully resolved. The function should expect a single argument: the promise's resolved value.
opt_errback: Function=
The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.
Returns
A new promise which will be resolved with the result of the invoked callback.

Registers a listener for when this promise is rejected. This is synonymous with the catch clause in a synchronous API:


   // Synchronous API:
   try {
     doSynchronousWork();
   } catch (ex) {
     console.error(ex);
   }

   // Asynchronous promise API:
   doAsynchronousWork().thenCatch(function(ex) {
     console.error(ex);
   });
 
Parameters
errback: !Function
The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.
Returns
A new promise which will be resolved with the result of the invoked callback.

Registers a listener to invoke when this promise is resolved, regardless of whether the promise's value was successfully computed. This function is synonymous with the finally clause in a synchronous API:


   // Synchronous API:
   try {
     doSynchronousWork();
   } finally {
     cleanUp();
   }

   // Asynchronous promise API:
   doAsynchronousWork().thenFinally(cleanUp);
 
Note: similar to the finally clause, if the registered callback returns a rejected promise or throws an error, it will silently replace the rejection error (if any) from this promise:

   try {
     throw Error('one');
   } finally {
     throw Error('two');  // Hides Error: one
   }

   webdriver.promise.rejected(Error('one'))
       .thenFinally(function() {
         throw Error('two');  // Hides Error: one
       });
 
Parameters
callback

Instance Properties

Defined in webdriver.Alert

Defined in webdriver.promise.Deferred

Represents the eventual value of a completed operation. Each promise may be in one of three states: pending, resolved, or rejected. Each promise starts in the pending state and may make a single transition to either a fulfilled or failed state.

This class is based on the Promise/A proposal from CommonJS. Additional functions are provided for API compatibility with Dojo Deferred objects.

Static Properties