closeApp
Close a specific app or the currently active app on the device.
Note: Falls back to the deprecated Appium 2 protocol endpoint if the driver does not support the
mobile:execute method.
If no bundleId (iOS) or appId (Android) is provided, the command will automatically detect and close the currently active app.
Usage
browser.closeApp({ bundleId, appId })
Parameters
| Name | Type | Details |
|---|---|---|
optionsoptional | object | Options for closing the app (optional) |
options.bundleIdoptional | string | The bundle ID of the iOS app to close. If not provided, the currently active app is closed. iOS-ONLY |
options.appIdoptional | string | The package name of the Android app to close. If not provided, the currently active app is closed. ANDROID-ONLY |
Example
closeApp.js
it('should close the currently active app', async () => {
// Automatically close the currently active app
await browser.closeApp()
})
it('should close a specific iOS app by bundleId', async () => {
// iOS: close a specific app using its bundle ID
await browser.closeApp({ bundleId: 'com.example.myapp' })
})
it('should close a specific Android app by appId', async () => {
// Android: close a specific app using its package name
await browser.closeApp({ appId: 'com.example.myapp' })
})
Support
नोट
Refer to the official Appium driver documentation to see which driver versions support this command.