Skip to main content

accept

Accepts the dialog and returns when the dialog has been handled.

info

Only works with browser dialogs (via BiDi protocol). For mobile native dialogs, use browser.acceptDialog instead.

Usage

await dialog.accept(promptText)

Parameters

NameTypeDetails
promptText
optional
stringA text to enter into prompt. Does not cause any effects if the dialog's type is not prompt.

Example

dialogAccept.js
// Listen for the dialog event to get the dialog object
browser.on('dialog', async (dialog) => {
console.log(dialog.message()); // prints: 'Hello, world!'
await dialog.accept();
});

// Or accept a prompt dialog with text
browser.on('dialog', async (dialog) => {
if (dialog.type() === 'prompt') {
await dialog.accept('my input');
}
});

Welcome! How can I help?

WebdriverIO AI Copilot