alertDismiss

Dismisses the currently displayed alert dialog. For confirm() and prompt() dialogs, this is equivalent to clicking the ‘Cancel’ button. For alert() dialogs, this is equivalent to clicking the ‘OK’ button.

Usage

1
browser.alertDismiss();

Example

alertAccept.js
1
2
3
4
5
6
7
8
it('demonstrate the alertDismiss command', function () {
try {
browser.alertDismiss();
} catch (e) {
// no alert found
}
// ...
});

Throws

  • RuntimeError: If no alert is present. The seleniumStack.type parameter will equal ‘NoAlertOpenError’.