Hoppa till huvudinnehåll

dismissDialog

Dismiss a native mobile alert or permission dialog.

Unlike browser dialogs which emit a dialog event, mobile permission dialogs and system alerts are already on screen when the test reaches them. Call this command to dismiss the dialog in place.

info

This command only works with the following up-to-date components:

  • Appium server (version 2.0.0 or higher)
  • appium-uiautomator2-driver (for Android)
  • appium-xcuitest-driver (for iOS)

Make sure your local or cloud-based Appium environment is regularly updated to avoid compatibility issues.

Usage

await browser.dismissDialog(buttonText)

Parameters

NameTypeDetails
buttonText
optional
stringThe text of the button to tap (e.g. Cancel, Don't Allow, No). If omitted, the default dismiss action is used.

Example

dismissDialog.js
it('should dismiss a permission dialog', async () => {
// Dismiss an iOS permission dialog by button label
await browser.dismissDialog("Don't Allow")

// Dismiss an Android alert
await browser.dismissDialog('Cancel')

// Dismiss whatever the default/cancel button is
await browser.dismissDialog()
})

Support

Support for ios Support for android

Supported platforms: iOS, Android

anteckning

Refer to the official Appium driver documentation to see which driver versions support this command.

Welcome! How can I help?

WebdriverIO AI Copilot