# type

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

info

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

## Usage[​](#usage "Direct link to Usage")

```
await dialog.type()
```

## Example[​](#example "Direct link to 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[​](#returns "Direct link to Returns")

* **\<string>** **`returns`:** The type of the dialog
