Automated test Monkeyrunner, adb shell automatically enters Chinese into Android app

Source: Internet
Author: User

In doing some Android automation scripts, such as the mobile phone QQ input Chinese chat content, due to the use of Robotium, Appium and other tools to do, because of TX signed verification, so log on QQ. Later only use the most stupid monkeyrunner to do, but it is completely simulated human clicks, and the data Chinese is very troublesome. To this end we have tried a variety of options, simply share:

1. Through the PC Clipboard and the Android simulator to share to achieve: the first to be entered in Chinese to the PC Clipboard, and then to the Android emulator paste into the QQ chat input box. Its disadvantage is, very unstable, sometimes successful, sometimes more inexplicable failure.

2. The ADB shell Input command can directly enter a string into the input box for the Android application, but the problem is that it does not support Unicode characters (only ASICC characters are supported). So I found a way to use the data on the Web to output the Unicode character as it is, and then convert it to the encoded character. For example: HTTPS://GITHUB.COM/BINGWEI/INPUTCHINESEVIAADB, the implementation of such a transformation, in the app copied to the Android clipboard, and then can be in the QQ chat boxes and other places to paste the good. Of course, there's a little bug in the utils/inputunicode.py file in this Gitlab project, and for Python 2.x, you need to encode encode (' Unicode-escape ') in the string followed by the ADB shell input.
The speed of this method is not very fast, but it is still good, because the UI Automation delay for a two seconds is also acceptable; we finally adopted this scheme, and now it is very stable to run.

3. Use an external rest server, make a key-value pair into rest sever, where key is in all English, and value can contain Chinese, and then pass the key into andoid through adb shell input, In Android, the remote Rest API is requested based on key to obtain value containing the Chinese character. This method has not been tried, but it should be feasible, but its efficiency estimate is less efficient than the 2nd method.

4. A special input method for Unicode, you can enter Unicode for adb shell input, which helps you to convert to characters such as Chinese. Never really tried.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.