.alerts.getText() Suggest edits
Get the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.
Usage
.alerts.getText([callback])
Example
module.exports = {
'get open alert text': function (browser) {
browser
.alerts.getText(function (result) {
console.log('text on open alert:', result.value);
});
},
'get open alert text with ES6 async/await': async function (browser) {
const alertText = await browser.alerts.getText();
console.log('text on open alert:', alertText);
}
};
Parameters
Name | Type | description |
---|---|---|
callback Optional |
function | Callback function which is called with the result value. |
Returns
Type | description |
---|---|
string | The text of the currently displayed alert. |