queryAppState
Get the state of a given application on the device.
Note: Falls back to the deprecated Appium 2 protocol endpoint if the driver does not support the
mobile:execute method.
Returns one of the following numeric states:
0— Not installed1— Not running2— Running in background (suspended)3— Running in background4— Running in foreground
Usage
browser.queryAppState(appId, bundleId)
Parameters
| Name | Type | Details |
|---|---|---|
appIdoptional | string | Application package name (Android). |
bundleIdoptional | string | Application bundle identifier (iOS). |
Example
queryAppState.js
it('should get the app state', async () => {
// Check app state on Android
const state = await browser.queryAppState('com.example.app')
// Check app state on iOS
const iosState = await browser.queryAppState(undefined, 'com.example.app')
})
Returns
- <
Promise<number>>returns: The application state (0–4).
Support
uwaga
Refer to the official Appium driver documentation to see which driver versions support this command.