alertText

Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.

Usage

1
browser.alertText([text]);

Parameters

Param Type Details
text
optional
String Keystrokes to send to the prompt() dialog.

Example

alertText.js
1
2
3
4
5
it('demonstrate the alertText command', function () {
let alert = browser.alertText();
expect(alert).toEqual('There are unsaved changes on the page.');
// ...
});

Returns

  • <String>: The text of the currently displayed alert.

Throws

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