Appium 无法使用 keyevent,报错 Injecting to another application requires INJECT_EVENTS permission

猫大白 · 2017年04月26日 · 1198 次阅读
 info: --> POST /wd/hub/session/4b60ed75-3aba-4eb7-8f74-3876137c0f69/element {"using":"name","value":"start"}
> info: [debug] Waiting up to 30000ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"start","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"start","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding start using NAME with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=start, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}}
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"4b60ed75-3aba-4eb7-8f74-3876137c0f69"}
> info: <-- POST /wd/hub/session/4b60ed75-3aba-4eb7-8f74-3876137c0f69/element 200 238.668 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"4b60ed75-3aba-4eb7-8f74-3876137c0f69"}
> info: --> POST /wd/hub/session/4b60ed75-3aba-4eb7-8f74-3876137c0f69/execute {"script":"mobile: longClick","args":[{"element":"1"}]}
> info: [debug] Pushing command to appium work queue: ["element:touchLongClick",{"elementId":"1"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchLongClick","params":{"elementId":"1"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: touchLongClick
> info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Injecting to another application requires INJECT_EVENTS permission"},"sessionId":"4b60ed75-3aba-4eb7-8f74-3876137c0f69"}
> info: <-- POST /wd/hub/session/4b60ed75-3aba-4eb7-8f74-3876137c0f69/execute 500 129.590 ms - 235 
> info: --> DELETE /wd/hub/session/4b60ed75-3aba-4eb7-8f74-3876137c0f69 {}
> info: Shutting down appium session
> info: [debug] Pressing the HOME button
> info: [debug] executing cmd: "D:\Program Files\Android\android-sdk\platform-tools\adb.exe" -s 2cfac4ff7d02 shell "input keyevent 3"
> info: [debug] [BOOTSTRAP] [debug] Performing TouchLongClick using element? true x: 360, y: 1157, duration: 2000
> info: [debug] [BOOTSTRAP] [error] error while invoking method private boolean com.android.uiautomator.core.InteractionController.touchDown(int,int) on object com.android.uiautomator.core.InteractionController@64d3fcc with parameters [360, 1157] null
> info: [debug] [BOOTSTRAP] [debug] Problem invoking correct long click: java.lang.RuntimeException: error while invoking method private boolean com.android.uiautomator.core.InteractionController.touchDown(int,int) on object com.android.uiautomator.core.InteractionController@64d3fcc with parameters [360, 1157]
> info: [debug] [BOOTSTRAP] [debug] Falling back to broken longClick
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":13,"value":"Injecting to another application requires INJECT_EVENTS permission"}
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] Stopping chromedriver for context WEBVIEW_io.dcloud.H5C4DBE11
> info: Chromedriver: Changed state to 'stopping'
> info: JSONWP Proxy: Proxying [DELETE /] to [DELETE http://127.0.0.1:9515/wd/hub/session/8ddaac46f1ed87588c6b15ae60cef21b] with no body
> info: JSONWP Proxy: Got response with status 200: "{\"sessionId\":\"8ddaac46f1ed87588c6b15ae60cef21b\",\"status\":0,\"value\":null}"
> info: Chromedriver: Changed state to 'stopped'
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
> info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN

Injecting to another application requires INJECT_EVENTS permission 网上查了些资料,有说是因为软键盘没关闭,于是在输入完成后关闭了键盘 driver.hideKeyboard();
本来想用 driver.pressKeyCode(AndroidKeyCode.BACK);也是一直报这个错

也找开发获得了这个权限 INJECT_EVENTS,但是没效果

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册