Appium solve Chinese input problems

Source: Internet
Author: User

Article source http://blog.csdn.net/meyoung01/article/details/43286265

Appium not support Chinese, waste a good big strength have not done. Finally with a soil approach to settle, directly see the package of code: [Java] View plain copy/*** Enter Chinese, and return * *@paramDriver Driver *@paramtext For example to enter "China" is the value of "Zhongguo" *@paramby locate the control you want to get text for *@return  */   Public Staticstring SendText (androiddriver driver, string text, by) {string Returntext=NULL; Try{Thread.Sleep (2000); Process Pro= Runtime.getruntime (). EXEC ("cmd/c adb shell input text" +text); Thread.Sleep (1500); Runtime.getruntime (). EXEC ("cmd/c adb shell input keyevent keycode_space"); Thread.Sleep (2000); Returntext=driver.findelement (by). GetText (); } Catch(IOException e) {}Catch(interruptedexception e) {e.printstacktrace (); }      returnReturntext; Note that when this method is called, the keyboard must be set to the default system keyboard, and the keyboard can be entered in Chinese. Accidental discovery has already supported the input of Chinese characters, as long as the following two items can be added in capabilities: Capabilities.setcapability ("Unicodekeyboard", "True"); Capabilities.setcapability ("Resetkeyboard", "True");


Note When this method is called, the keyboard must be set to the default system keyboard, and the keyboard can be entered in Chinese.

Accidental discovery has actually supported the input of Chinese characters,

Just add the following two settings to the capabilities:

Capabilities.setcapability ("Unicodekeyboard", "True");
Capabilities.setcapability ("Resetkeyboard", "True");

Appium solve Chinese input problems

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.