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

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 installed
  • 1 — Not running
  • 2 — Running in background (suspended)
  • 3 — Running in background
  • 4 — Running in foreground
Usage
browser.queryAppState(appId, bundleId)
Parameters
NameTypeDetails
appId
optional
stringApplication package name (Android).
bundleId
optional
stringApplication 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

Support for ios Support for android

ghi chú

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

Welcome! How can I help?

WebdriverIO AI Copilot