Chuyển đến nội dung chính

type

Returns dialog's type, can be one of alert, beforeunload, confirm or prompt.

thông tin

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

Usage​

await dialog.type()

Example​

dialogType.js
// Listen for the dialog event to get the dialog object
browser.on('dialog', async (dialog) => {
const type = await dialog.type();
console.log(type); // prints: 'alert', 'confirm', 'prompt', or 'beforeunload'
});

Returns​

  • <string> returns: The type of the dialog

Welcome! How can I help?

WebdriverIO AI Copilot