[Appium] Avoid “Security exception: adb clearing user data is forbidden” for Chrome in some Android devices

Some devices deny calling adb pm clean by their customization. Afaik, some Chinese devices such as Oppo have.

In Appium, such an error could occur when an appium capabilities have noReset is false and fullReset is false. The combination is its default value. To avoid the error, noReset should be true (skip the cleaning) or fullReset is true (re-install the app under test). The fullReset is true can do only when a app capability is given.

In chrome browser testing case, such fullReset strategy does not work since generally, the capability does not have app. It should be only bundleId or just browserName: chrome.

According to this comment, newer chromedrivers have androidKeepAppDataDir to clear the chrome browser data as its chromeOptions. By this, you can clear a chrome browser’s local data in an Android phone that raises Security exception: adb clearing user data is forbidden by adb pm clean.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.