Skip to main content

defaultValue

If dialog is prompt, returns default prompt value. Otherwise, returns empty string.

info

Only works with browser dialogs (via BiDi protocol). Native mobile dialogs do not expose a default value through WebDriver. Use browser.acceptDialog or browser.dismissDialog to handle them.

Usage

await dialog.defaultValue()

Example

dialogDefaultValue.js
// Listen for the dialog event to get the dialog object
browser.on('dialog', async (dialog) => {
if (dialog.type() === 'prompt') {
const value = await dialog.defaultValue();
console.log(value); // prints the default prompt value
}
});

Returns

  • <string> returns: The default prompt value, or empty string if not a prompt.

Welcome! How can I help?

WebdriverIO AI Copilot