使用 Appium 驱动小米 5 手机打开 APP 时,报 adb 命令没有权限:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command 'E:\SDK\Android\platform-tools\adb.exe -P 5037 -s 8585d58 shell pm clear com.hexin.plat.android' exited with code 1'; Stderr: 'Error: java.lang.SecurityException: PID 9050 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.hexin.plat.android'; Code: '1'
通过 CMD 敲 adb shell 后,进入的是 gemini:/ $,符号的 $ 而不是 # 号,执行 su 提示/system/bin/sh: su: not found,请教下要怎么解决 appium 执行 adb 命令无权限的问题,不胜感激!
代码:
import time
import unittest
from appium import webdriver
class APPCenter(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7.0'
desired_caps['deviceName'] = '8585d58'
#desired_caps['app'] = 'D:\123.apk'
desired_caps['appPackage']= 'com.hexin.plat.android'
desired_caps['appActivity'] = 'com.huawei.hms.activity.BridgeActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub,desired_caps')
time.sleep(5)
def test_sample(self):
time.sleep(5)
def tearDown(self):
self.driver.quit()
if name == 'main':
unittest.main()