我最近在这里学习appium,当我设置所需的所有信息时,出现了错误。这是appium日志:
[debug] [ADB] Running 'D:\Android\sdk\platform-tools\adb.exe' with args: ["-
P",5037,"-s","ZY223MPGDF","shell","am","force-stop","io.appium.unlock"]
[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles`
capability if wanted.
[MJSONWP] Encountered internal error running command: Error: Error occured
while starting App. Original error: Error executing adbExec. Original error:
'Command 'D\:\\Android\\sdk\\platform-tools\\adb.exe -P 5037 -s ZY223MPGDF
shell am start -W -n ai.zuoye.app/com.homework.app.activity.HomeActivity -S
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f
0x10200000' exited with code 1'; Stderr: 'java.lang.SecurityException:
Permission Denial: starting Intent { act=android.intent.action.MAIN cat=
[android.intent.category.LAUNCHER] flg=0x10200000
cmp=ai.zuoye.app/com.homework.app.activity.HomeActivity } from null
(pid=9092, uid=2000) not exported from uid 10213
at android.os.Parcel.readException(Parcel.java:1684)
at android.os.Parcel.readException(Parcel.java:1637)
at android.app.ActivityManagerProxy.startActivityAndWait(ActivityManagerNative.java:3282)
at com.android.commands.am.Am.runStart(Am.java:634)
at com.android.commands.am.Am.onRun(Am.java:390)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
at com.android.commands.am.Am.main(Am.java:122)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)'; Code: '1'
at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13)
at ADB.callee$0$0$ (../../../lib/tools/apk-utils.js:101:9)
at tryCatch (C:\Users\Glority\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Glority\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\Glority\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (C:\Users\Glority\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
[HTTP] <-- POST /wd/hub/session 500 31691 ms - 1369
我看到它说权限否认,但我可以用它来启动手机计算器,我不知道这个。这是我的代码:
import os
import sys
import unittest
from time import sleep
from appium import webdriver
class hh (unittest.TestCase):
def test_addContent(self):
desire_caps={}
desire_caps['platformName']='Android'
desire_caps['platformVersion']='7.1.1'
desire_caps['appPackage']='ai.zuoye.app'
desire_caps['appActivity']='com.homework.app.activity.HomeActivity'
desire_caps['deviceName']='ZY223MPGDF'
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub",desire_caps)
sleep(10)
driver.quit()
if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(hh)
unittest.TextTestRunner(verbosity=2).run(suite)
谢谢!
检查几件事
1)确保您的开发人员选项已打开并启用了USB调试选项
2)检查你是否可以通过adb命令打开手机应用程序
3)检查您的设备是否通过运行命令adb devices授权。如果未经授权将其授权