appium 支持輸入中文

加入:
desired_caps['unicodeKeyboard'] = True

desired_caps['resetKeyboard'] = True

使用輸入中文:android

input_txt = driver.find_element_by_id('cn.com.taodaji:id/search_edit')
input_txt.send_keys(u'測試')

 上述代碼改變了手機默認輸入法爲 resetKeyboard , 這時再輸入字符或數字時,會出現輸入不徹底的問題,能夠用如下方式切換輸入法:shell

import os

#列出系統如今所安裝的全部輸入法 -a
cmd0 ='adb shell ime list -s'

#打印系統當前默認的輸入法
cmd1 ='adb shell settings get secure default_input_method'

#切換輸入法
cmd2 ='adb shell ime set com.sohu.inputmethod.sogouoem/.SogouIME'
cmd3 ='adb shell ime set io.appium.android.ime/.UnicodeIME'

def enable_sougou():
    print (cmd2)
    os.system(cmd2)

def enable_unicode():
    os.system(cmd3)
相關文章
相關標籤/搜索