Appium UiAutomator2 Driver is a test automation framework for Android devices. Appium UiAutomator2 Driver automates native, hybrid and mobile web apps, tested on emulators and real devices. Appium UiAutomator2 Driver is part of the Appium mobile test automation tool. The driver operates in scope of W3C WebDriver protocol with several custom extensions to cover operating-system specific scenarios.
UiAutomator2 Driver proxies most of the commands to UiAutomator2 server, which uses Google's UiAutomator framework under the hood. Some commands are proxied directly to appium-adb and other helpers built on top of Android platform tools.
See the end-to-end architecture diagram.
[!IMPORTANT] Since major version 5.0.0, this driver is only compatible with Appium 3. Use the
appium driver install uiautomator2command to add it to your distribution.
On top of standard Appium requirements UiAutomator2 driver also expects the following prerequisites:
online in adb devices -l output.Since driver version 2.39.0 you can automate the validation for the most of the above
requirements as well as various optional ones needed by driver extensions by running the
appium driver doctor uiautomator2 server command.
| Capability Name | Description |
|---|---|
| platformName | Could be set to android. Appium itself is not strict about this capability value if automationName is provided, so feel free to assign it to any supported platform name if this is needed, for example, to make Selenium Grid working. |
| appium:automationName | Must always be set to uiautomator2. Values of automationName are compared case-insensitively. |
| appium:deviceName | The name of the device under test (actually, it is not used to select a device under test). Consider setting udid for real devices and avd for emulators instead |
| appium:platformVersion | The platform version of an emulator or a real device. This capability is used for device autodetection if udid is not provided |
| appium:udid | UDID of the device to be tested. Could be retrieved from adb devices -l output. If unset then the driver will try to use the first connected device. Always set this capability if you run parallel tests. |
| appium:noReset | Prevents the device to be reset before the session startup if set to true. This means that the application under test is not going to be terminated neither its data cleaned. false by default |
| appium:fullReset | Being set to true always enforces the application under test to be fully uninstalled before starting a new session. false by default |
| appium:printPageSourceOnFindFailure | Enforces the server to dump the actual XML page source into the log if any error happens. false by default. |
| Capability Name | Description |
|---|---|
| appium:systemPort | The number of the port on the host machine used for the UiAutomator2 server. By default the first free port from 8200..8299 range is selected. It is recommended to set this value if you are running parallel tests on the same machine. |
| appium:skipServerInstallation | Skip the UiAutomator2 Server component installation on the device under test and all the related checks if set to true. This could help to speed up the session startup if you know for sure the correct server version is installed on the device. In case the server is not installed or an incorrect version of it is installed then you may get an unexpected error later. false by default |
| appium:uiautomator2ServerLaunchTimeout | The maximum number of milliseconds to wait util UiAutomator2Server is listening on the device. 30000 ms by default |
| appium:uiautomator2ServerInstallTimeout | The maximum number of milliseconds to wait util UiAutomator2Server is installed on the device. 20000 ms by default |
| appium:uiautomator2ServerReadTimeout | The maximum number of milliseconds to wait for a HTTP response from UiAutomator2Server. Only values greater than zero are accepted. If the given value is too low then expect driver commands to fail with timeout of Xms exceeded error. 240000 ms by default |
| appium:disableWindowAnimation | Whether to disable window animations when starting the instrumentation process. The animation scale will be restored automatically after the instrumentation process ends for API level 26 and higher. The animation scale could remain if the session ends unexpectedly for API level 25 and lower. false by default |
| appium:skipDeviceInitialization | If set to true then device startup checks (whether it is ready and whether Settings app is installed) will be canceled on session creation. Could speed up the session creation if you know what you are doing. false by default |
| Capability Name | Description |
|---|---|
| appium:app | Full path to the application to be tested (the app must be located on the same machine where the server is running). Both .apk and .apks application extensions are supported. Could also be an URL to a remote location. If neither of the app, appPackage or browserName capabilities are provided then the driver starts from the Dashboard and expects the test knows what to do next. Do not provide both app and browserName capabilities at once. |
| browserName | The name of the browser to run the test on. If this capability is provided then the driver will try to start the test in Web context mode (Native mode is applied by default). Read Automating hybrid apps for more details. Usually equals to chrome. |
| appium:appPackage | Application package identifier to be started. If not provided then UiAutomator2 will try to detect it automatically from the package provided by the app capability. Read How To Troubleshoot Activities Startup for more details |
| appium:appActivity | Main application activity identifier. If not provided then UiAutomator2 will try to detect it automatically from the package provided by the app capability. Read How To Troubleshoot Activities Startup for more details |
| appium:appWaitActivity | Identifier of the first activity that the application invokes. If not provided then equals to appium:appActivity. Read How To Troubleshoot Activities Startup for more details |
| appium:appWaitPackage | Identifier of the first package that is invoked first. If not provided then equals to appium:appPackage. Read How To Troubleshoot Activities Startup for more details |
| appium:appWaitDuration | Maximum amount of milliseconds to wait until the application under test is started (e. g. an activity returns the control to the caller). 20000 ms by default. Read How To Troubleshoot Activities Startup for more details |
| appium:androidInstallTimeout | Maximum amount of milliseconds to wait until the application under test is installed. 90000 ms by default |
| appium:appWaitForLaunch | Whether to block until the app under test returns the control to the caller after its activity has been started by Activity Manager (true, the default value) or to continue the test without waiting for that (false). |
| appium:intentCategory | Set an optional intent category to be applied when starting the given appActivity by Activity Manager. Defaults to android.intent.category.LAUNCHER. Please use mobile:startActivity in case you don't set an explicit value. |
| appium:intentAction | Set an optional intent action to be applied when starting the given appActivity by Activity Manager. Dfaults to android.intent.action.MAIN. Please use mobile:startActivity in case you don't set an explicit value. |
| appium:intentFlags | Set an optional intent flags to be applied when starting the given appActivity by Activity Manager. Defaults to 0x10200000 (FLAG_ACTIVITY_NEW_TASK |
| appium:optionalIntentArguments | Set an optional intent arguments to be applied when starting the given appActivity by Activity Manager |
| appium:dontStopAppOnReset | Set it to true if you don't want the application to be restarted if it was already running. If appium:noReset is falsy, then the app under test is going to be restarted if either this capability is falsy (the default behavior) or appium:forceAppLaunch is set to true. false by default |
| appium:forceAppLaunch | Set it to true if you want the application under test to be always forcefully restarted on session startup even if appium:noReset is true, and the app was already running. If noReset is falsy, then the app under test is going to be restarted if either this capability set to true or appium:dontStopAppOnReset is falsy (the default behavior). false by default. Available since driver version 2.12 |
| appium:shouldTerminateApp | Set it to true if you want the application under test to be always terminated on session end even if appium:noReset is true. If noReset is falsy, then the app under test is going to be terminated if appium:dontStopAppOnReset is also falsy (the default behavior). false by default |
| appium:autoLaunch | Whether to launch the application under test automatically (true, the default value) after a test starts |
| appium:autoGrantPermissions | Whether to grant all the requested application permissions automatically when a test starts(true). The targetSdkVersion in the application manifest must be greater or equal to 23 and the Android version on the device under test must be greater or equal to Android 6 (API level 23) to grant permissions. Applications whose targetSdkVersion is lower than or equal to 22 must be reinstalled to grant permissions, for example, by setting the appium:fullReset capability as true for Android 6+ devices. If your app needs some special security permissions, like access to notifications or media recording, consider using mobile: changePermissions extension with appops target. false by default |
| appium:otherApps | Allows to set one or more comma-separated paths to Android packages that are going to be installed along with the main application under test. This may be useful if the tested app has dependencies |
| appium:uninstallOtherPackages | Allows to set one or more comma-separated package identifiers to be uninstalled from the device before a test starts |
| appium:allowTestPackages | If set to true then it would be possible to use packages built with the test flag for the automated testing (literally adds -t flag to the adb install command). false by default |
| appium:remoteAppsCacheLimit | Sets the maximum amount of application packages to be cached on the device under test. This is needed for devices that don't support streamed installs (Android 7 and below), because ADB must push app packages to the device first in order to install them, which takes some time. Setting this capability to zero disables apps caching. 10 by default. |
| appium:enforceAppInstall | If set to true then the application under test is always reinstalled even if a newer version of it already exists on the device under test. This capability has no effect if appium:noReset is set to true. false by default. |
| Capability Name | Description |
|---|---|
| appium:localeScript | Canonical name of the locale to be set for the app under test, for example Hans in zh-Hans-CN. See https://developer.android.com/reference/java/util/Locale.html for more details. |
| appium:language | Name of the language to extract application strings |
$ claude mcp add appium-uiautomator2-driver \
-- python -m otcore.mcp_server <graph>