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:
Defer returning text until the promised alert has been resolved.
Overrides: webdriver.Alert
thenFinally(callback)code »
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
}
promise.rejected(Error('one'))
.thenFinally(function() {
throw Error('two'); // Hides Error: one
});
Specified by: webdriver.promise.Thenable
Parameters
- callback
function(): (R|IThenable<R>)
The function
to call when this promise is resolved.