Executing ADB commands from the script

Hi Team,

I want to execute adb shell pm clear <package-name> command in after() block of my script.

I tried 2 things:

  1. Use below piece of code in after() block but it gave me error:

await driver.executeScript(‘mobile: shell’, [{
command: ‘pm clear’,**
args: [‘com.gelato.api.stage’],**

unknown error: An unknown server-side error occurred while processing the command. Original error: Potentially insecure feature ‘adb_shell’ has not been enabled. If you want to enable this feature and accept the security ramifications, please do so by following the documented instructions at https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/security.md
at async Context. (/Users/harsha.sharma/Dev/work/sandbox/repo/integration-tests/src/specs/android/login.spec.ts:17:6)

To resolve this issue, I also tried to execute appium command in wdio.config by including below section of code in my wdio.config but this also did not solved my issue.

appium: {
command: ‘appium --relaxed-security --allow-insecure=adb_shell --chromedriver-executable /Users/harsha.sharmagelato.com/Dev/work/sandbox/gelato-api-mobile/integration-tests/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v91.0.4472.101’,
// args: [‘–allow-insecure’, ‘chromedriver_autodownload’],

  1. Then I also tried after installing appium-adb, this also did not work for me.

Can someone please guide me how should I solve this issue?

Thanks :slight_smile:

Why not make a system call?


I am not sure if it will be helpful in my case. My project is in TypeScript and I doubt if there is any system call through which I can logout my app after completing my testExecution.

I think it will be better either to use any ADB command or some appium webdriverIO function which will help me to accomplish this.
What are your thoughts on this ?

My thoughts are you know where the documentation is, knock yourself out. Keep in mind that you may find a system call is the best solution. It’s your project, so I encourage you to do it your way.