{"action":"created","issue":{"url":"https://api.github.com/repos/appium/appium-uiautomator2-server/issues/123","repository_url":"https://api.github.com/repos/appium/appium-uiautomator2-server","labels_url":"https://api.github.com/repos/appium/appium-uiautomator2-server/issues/123/labels{/name}","comments_url":"https://api.github.com/repos/appium/appium-uiautomator2-server/issues/123/comments","events_url":"https://api.github.com/repos/appium/appium-uiautomator2-server/issues/123/events","html_url":"https://github.com/appium/appium-uiautomator2-server/issues/123","id":304760302,"number":123,"title":"start appium with automationName=uiautomator2, pressKeyCode() doesn't work!","user":{"login":"gogoda","id":18298671,"avatar_url":"https://avatars3.githubusercontent.com/u/18298671?v=4","gravatar_id":"","url":"https://api.github.com/users/gogoda","html_url":"https://github.com/gogoda","followers_url":"https://api.github.com/users/gogoda/followers","following_url":"https://api.github.com/users/gogoda/following{/other_user}","gists_url":"https://api.github.com/users/gogoda/gists{/gist_id}","starred_url":"https://api.github.com/users/gogoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogoda/subscriptions","organizations_url":"https://api.github.com/users/gogoda/orgs","repos_url":"https://api.github.com/users/gogoda/repos","events_url":"https://api.github.com/users/gogoda/events{/privacy}","received_events_url":"https://api.github.com/users/gogoda/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-13T13:16:53Z","updated_at":"2018-03-23T05:19:57Z","closed_at":null,"author_association":"NONE","body":"####  when i use  `automationName=uiautomator2`  in my desired capabilities, then the pressKeyCode method doesn't work, and appium server without any error message.\r\n#### when i change the desired capabilities with `automationName=Appium`  and restart my project, pressKeyCode method will be work fine.\r\n#### I have no idea on this, wish reply!  thanks\r\n\r\n***\r\n***\r\n\r\n`appium server : v1.7.3`\r\n```\r\n<dependency>\r\n      <groupId>io.appium</groupId>\r\n      <artifactId>java-client</artifactId>\r\n      <version>5.0.4</version>\r\n</dependency>\r\n```\r\n*** \r\n- **property in the desired capabilities**\r\n```\r\nserverURL=http://127.0.0.1:4723/wd/hub\r\nautomationName=uiautomator2\r\nplatformName=Android\r\nplatformVersion=5.1.1\r\ndeviceName=vivo X6SPlus D\r\n```\r\n\r\n- **pressKeyCode method**\r\n```    \r\n    public void keyboardSearch() {\r\n        AndroidDriver androidDriver = convertAndroidDriver();\r\n        if (androidDriver != null) {\r\n            androidDriver.pressKeyCode(AndroidKeyCode.ENTER);\r\n        }\r\n    } \r\n```\r\n\r\n- **appium server logs**\r\n```\r\n[2018-03-13 08:26:30][HTTP] <-- POST /wd/hub/session/2551ef26-f71b-4eb6-89a7-a05f72c10ee4/element/49329a07-179f-4759-843c-da9b9a1d21dd/value 200 67 ms - 74 \r\n[2018-03-13 08:26:30][HTTP] --> POST /wd/hub/session/2551ef26-f71b-4eb6-89a7-a05f72c10ee4/appium/device/press_keycode {\"keycode\":66}\r\n[2018-03-13 08:26:30][MJSONWP] Calling AppiumDriver.pressKeyCode() with args: [66,null,null,null,\"2551ef26-f71b-4eb6-89a7-a05f72c10ee4\"]\r\n[2018-03-13 08:26:30][JSONWP Proxy] Proxying [POST /appium/device/press_keycode] to [POST http://localhost:8206/wd/hub/session/b5441807-e0eb-482e-ab5e-02ffe7c6b0d3/appium/device/press_keycode] with body: {\"keycode\":66,\"metastate\":null}\r\n[2018-03-13 08:26:32][JSONWP Proxy] Got response with status 200: {\"sessionId\":\"b5441807-e0eb-482e-ab5e-02ffe7c6b0d3\",\"status\":0,\"value\":true}\r\n[2018-03-13 08:26:32][MJSONWP] Responding to client with driver.pressKeyCode() result: true\r\n[2018-03-13 08:26:32][HTTP] <-- POST /wd/hub/session/2551ef26-f71b-4eb6-89a7-a05f72c10ee4/appium/device/press_keycode 200 616 ms - 76 \r\n[2018-03-13 08:27:28][BaseDriver] Shutting down because we waited 60 seconds for a command\r\n[2018-03-13 08:27:28][UiAutomator2] Deleting UiAutomator2 session\r\n[2018-03-13 08:27:28][Appium] Closing session, cause was 'New Command Timeout of 60 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability'\r\n[2018-03-13 08:27:28][Appium] Removing session 2551ef26-f71b-4eb6-89a7-a05f72c10ee4 from our master session list\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/appium/appium-uiautomator2-server/issues/comments/375548200","html_url":"https://github.com/appium/appium-uiautomator2-server/issues/123#issuecomment-375548200","issue_url":"https://api.github.com/repos/appium/appium-uiautomator2-server/issues/123","id":375548200,"user":{"login":"gogoda","id":18298671,"avatar_url":"https://avatars3.githubusercontent.com/u/18298671?v=4","gravatar_id":"","url":"https://api.github.com/users/gogoda","html_url":"https://github.com/gogoda","followers_url":"https://api.github.com/users/gogoda/followers","following_url":"https://api.github.com/users/gogoda/following{/other_user}","gists_url":"https://api.github.com/users/gogoda/gists{/gist_id}","starred_url":"https://api.github.com/users/gogoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gogoda/subscriptions","organizations_url":"https://api.github.com/users/gogoda/orgs","repos_url":"https://api.github.com/users/gogoda/repos","events_url":"https://api.github.com/users/gogoda/events{/privacy}","received_events_url":"https://api.github.com/users/gogoda/received_events","type":"User","site_admin":false},"created_at":"2018-03-23T05:19:57Z","updated_at":"2018-03-23T05:19:57Z","author_association":"NONE","body":"finally I found the reason of this question.\r\n\r\nIn the process of using the UIA2, there is no reason for the input operation, and the focus is not on the input box, causing the ```pressKeyCode ()``` method to be invalid. (I doubt this is a bug of the UIA2 framework, hope can be confirmed)\r\n\r\nWhen the ```pressKeyCode ()``` method is called, the input box is re click first, and then the ```pressKeyCode ()``` method will work fine.\r\n\r\nAfter the input and click operations, you do not need to call the third party input application and continue to use ```io.appium.android.ime/.UnicodeIME```."}}
{"actor":{"display_login":"gogoda"}}