在 ((AndroidDriver) driver).sendKeyEvent(123);这行出错:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
查看日志发现是这个问题:
info: [debug] Pushing command to appium work queue: ["pressKeyCode",{"keycode":1
23,"metastate":null}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"pressKeyCode","params":{"keycode":123,"metastate":null}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: pressKeyCode
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":13,"value":"Inject
ing to another application requires INJECT_EVENTS permission"}
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"},"sessionI
d":"100e1428-5c8f-4d92-b761-d300c3ec1dc6"}