has been in the English test environment, including the mobile phone is also in English, the app is also in English, involving less than the Chinese input method of things. But now I'm writing a Chinese app, so I need to enter Chinese. See the following online solutions:
Download Https://github.com/sumio/uiautomator-unicode-input-helper Source code
Install utf7ime and change the default IME
- Import
Utf7Ime/
directory into your Eclipse workspace. You can import by File -> Import... -> Existing Android Code Into Workspace
.
- Build
Utf7Ime
Project and install it on the Your android-powered device (or emulator) for UI testing.
- Launch
Settings
App in the device.
- Open
Language & input
.
- Switch on the
UTF7 IME for UI Testing
checkbox belonging to KEYBOARD & INPUT METHODS
category.
- Tap
Default
belonging to KEYBOARD & INPUT METHODS
category.
- The change of the default IME to Utf7ime by selecting
UTF7 IME for UI Testing
.
Copy the helper library to your Uiautomator project
Copy helper-library/src/*
to <your uiaotomator project>/src/
.
The main idea is to import the Utf7ime project into eclipse after the download, build the Android project, generate the utf7ime.apk, install it into the test machine, and set the phone language as "UTF7 IME for UI testing";
Copy the source code under helper-library/src/* to the/src/of your Uiautomator test project.
That's what I'm doing here, just wrapping UTF7IMEHELPER.E () in the Commonhelper.java file, and then calling:
Then you can type in Chinese.
But here's the problem: After entering Chinese, click Enter to perform the search, but there is no keyboard present under the current UTF7 IME for UI testing IME, so you cannot click the ENTER key.
In order to solve this problem, I think of the solution is: to input Chinese, the input method into the UTF7 IME for UI testing, after input, then the input method to change back, so that the keyboard bounced out, and then click Enter, so that you can achieve the search.
Then there is another problem, how to implement fast switching input method: http://www.cnblogs.com/yajing-zh/p/5125317.html
Uiautomator Input Chinese